-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: removes empty interfaces and uses a json parser to reduce refle…
…ction usage Signed-off-by: Jennifer Power <[email protected]>
- Loading branch information
Showing
24 changed files
with
658 additions
and
296 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
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
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 |
---|---|---|
@@ -1 +1,76 @@ | ||
package attributes | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/emporous/emporous-go/model" | ||
) | ||
|
||
func TestListAttribute_Kind(t *testing.T) { | ||
test := NewList([]model.AttributeValue{ | ||
NewString("testvalue"), | ||
}) | ||
require.Equal(t, model.KindList, test.Kind()) | ||
} | ||
|
||
func TestListAttribute_AsBool(t *testing.T) { | ||
test := NewList([]model.AttributeValue{ | ||
NewString("testvalue"), | ||
}) | ||
s, err := test.AsBool() | ||
require.ErrorIs(t, ErrWrongKind, err) | ||
require.Equal(t, false, s) | ||
} | ||
|
||
func TestListAttribute_AsFloat(t *testing.T) { | ||
test := NewList([]model.AttributeValue{ | ||
NewString("testvalue"), | ||
}) | ||
s, err := test.AsFloat() | ||
require.ErrorIs(t, ErrWrongKind, err) | ||
require.Equal(t, float64(0), s) | ||
} | ||
|
||
func TestListAttribute_AsInt(t *testing.T) { | ||
test := NewList([]model.AttributeValue{ | ||
NewString("testvalue"), | ||
}) | ||
s, err := test.AsInt() | ||
require.ErrorIs(t, ErrWrongKind, err) | ||
require.Equal(t, int64(0), s) | ||
} | ||
|
||
func TestListAttribute_AsString(t *testing.T) { | ||
test := NewList([]model.AttributeValue{}) | ||
s, err := test.AsString() | ||
require.ErrorIs(t, ErrWrongKind, err) | ||
require.Equal(t, "", s) | ||
} | ||
|
||
func TestListAttribute_IsNull(t *testing.T) { | ||
test := NewList([]model.AttributeValue{ | ||
NewString("testvalue"), | ||
}) | ||
require.False(t, test.IsNull()) | ||
} | ||
|
||
func TestListAttribute_AsList(t *testing.T) { | ||
test := NewList([]model.AttributeValue{ | ||
NewString("testvalue"), | ||
}) | ||
s, err := test.AsList() | ||
require.NoError(t, err) | ||
require.Equal(t, []model.AttributeValue{NewString("testvalue")}, s) | ||
|
||
} | ||
|
||
func TestListAttribute_AsObject(t *testing.T) { | ||
test := NewList([]model.AttributeValue{ | ||
NewString("testvalue"), | ||
}) | ||
s, err := test.AsObject() | ||
require.ErrorIs(t, ErrWrongKind, err) | ||
require.Equal(t, map[string]model.AttributeValue(nil), s) | ||
} |
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
Oops, something went wrong.