-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yogesh Deshpande <[email protected]>
- Loading branch information
1 parent
aa0c483
commit a984e37
Showing
6 changed files
with
122 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package tdx | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func initAdvisoryIDs() []any { | ||
s := make([]any, len(TestAdvisoryIDs)) | ||
for i := range TestAdvisoryIDs { | ||
s[i] = TestAdvisoryIDs[i] | ||
} | ||
return s | ||
} | ||
|
||
func TestAdvisoryIDs_NewAdvisoryIDs_OK(t *testing.T) { | ||
a := initAdvisoryIDs() | ||
adv := NewAdvisoryIDs(a) | ||
require.NotNil(t, adv) | ||
} | ||
|
||
func TestAdvisoryIDs_NewAdvisoryIDs_NOK(t *testing.T) { | ||
a := make([]any, len(TestAdvisoryIDs)) | ||
for i := range TestAdvisoryIDs { | ||
a[i] = i | ||
} | ||
adv := NewAdvisoryIDs(a) | ||
require.Nil(t, adv) | ||
} | ||
|
||
func TestAdvisoryIDs_AddAdvisoryIDs_OK(t *testing.T) { | ||
a := initAdvisoryIDs() | ||
adv := TeeAdvisoryIDs{} | ||
err := adv.AddAdvisoryIDs(a) | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestAdvisoryIDs_AddAdvisoryIDs_NOK(t *testing.T) { | ||
expectedErr := "invalid type: float64 for AdvisoryIDs" | ||
s := make([]any, len(TestInvalidAdvisoryIDs)) | ||
for i := range TestInvalidAdvisoryIDs { | ||
s[i] = TestInvalidAdvisoryIDs[i] | ||
} | ||
adv := TeeAdvisoryIDs{} | ||
err := adv.AddAdvisoryIDs(s) | ||
assert.EqualError(t, err, expectedErr) | ||
} | ||
|
||
func TestAdvisoryIDs_Valid_OK(t *testing.T) { | ||
a := initAdvisoryIDs() | ||
adv := NewAdvisoryIDs(a) | ||
err := adv.Valid() | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestAdvisoryIDs_Valid_NOK(t *testing.T) { | ||
expectedErr := "empty AdvisoryIDs" | ||
adv := TeeAdvisoryIDs{} | ||
err := adv.Valid() | ||
assert.EqualError(t, err, expectedErr) | ||
|
||
expectedErr = "invalid type: float64 for AdvisoryIDs" | ||
s := make([]any, len(TestInvalidAdvisoryIDs)) | ||
for i := range TestInvalidAdvisoryIDs { | ||
s[i] = TestInvalidAdvisoryIDs[i] | ||
} | ||
adv = TeeAdvisoryIDs(s) | ||
err = adv.Valid() | ||
assert.EqualError(t, err, expectedErr) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters