Initial commit
This commit is contained in:
29
metadata_test.go
Normal file
29
metadata_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package metadata_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gopatchy/metadata"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type TestType struct {
|
||||
metadata.Metadata
|
||||
Text string
|
||||
}
|
||||
|
||||
func TestMetadata(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tt := &TestType{}
|
||||
|
||||
// Verify promoted field
|
||||
tt.ID = "abc123"
|
||||
|
||||
m := metadata.GetMetadata(tt)
|
||||
require.NotNil(t, m)
|
||||
require.Equal(t, "abc123", m.ID)
|
||||
|
||||
metadata.ClearMetadata(tt)
|
||||
require.Empty(t, tt.ID)
|
||||
}
|
||||
Reference in New Issue
Block a user