Files
trivy/pkg/notification/identifier_test.go
Owen Rumney 5a0bf9ed31 feat(cli): Add available version checking (#8553)
Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
Co-authored-by: Itay <itay@itaysk.com>
Co-authored-by: simar7 <1254783+simar7@users.noreply.github.com>
2025-05-28 08:09:16 +00:00

29 lines
851 B
Go

package notification
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGenerateMachineHash(t *testing.T) {
// Test with known input
identifier := "test-identifier"
hash := generateMachineHash(identifier)
// Known hash for "test-identifier"
expectedHash := "115ae872eb1d3e23f9de03f7ab344193b21068812ee52eb37e8169e6d093c7ae"
assert.Equal(t, expectedHash, hash)
}
// This test requires some modification to the original code to make it testable
// by injecting mocked network interfaces
func TestGetMachineIdentifier(t *testing.T) {
// This is a basic test that at least ensures the function returns without error
// A more complete test would mock os.Hostname and net.Interfaces
identifier, err := getMachineIdentifier()
require.NoError(t, err)
require.NotEmpty(t, identifier)
}