Skip to content

Commit

Permalink
chore(lint): fix lint errors in golang util package tests
Browse files Browse the repository at this point in the history
  • Loading branch information
b5 committed Jun 29, 2020
1 parent 2f560aa commit 2acf8d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
working_directory: /go/src/github.com/qri-io/starlib
docker:
- image: circleci/golang:1.12
- image: circleci/golang:latest
environment:
TEST_RESULTS: /tmp/test-results
GO111MODULE: "on"
Expand Down
20 changes: 11 additions & 9 deletions util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,19 @@ type invalidCustomType struct {

type customType invalidCustomType

func (t *customType) UnmarshalStarlark(v starlark.Value) error {
var (
_ Unmarshaler = (*customType)(nil)
_ Marshaler = (*customType)(nil)
_ starlark.Value = (*customType)(nil)
)

func (c *customType) UnmarshalStarlark(v starlark.Value) error {
// asserts
if v.Type() != "struct" {
return fmt.Errorf("not expected top level type, want struct, got %q", v.Type())
}
if _, ok := v.(*starlarkstruct.Struct).Constructor().(*customType); !ok {
return fmt.Errorf("not expected construct type got %T, want %T", v.(*starlarkstruct.Struct).Constructor(), t)
return fmt.Errorf("not expected construct type got %T, want %T", v.(*starlarkstruct.Struct).Constructor(), c)
}

// TODO: refactoring transform data
Expand All @@ -172,15 +178,15 @@ func (t *customType) UnmarshalStarlark(v starlark.Value) error {
data := starlark.StringDict{}
v.(*starlarkstruct.Struct).ToStringDict(data)

*t = customType{
*c = customType{
Foo: mustInt64(data["foo"]),
}
return nil
}

func (t *customType) MarshalStarlark() (starlark.Value, error) {
func (c *customType) MarshalStarlark() (starlark.Value, error) {
v := starlarkstruct.FromStringDict(&customType{}, starlark.StringDict{
"foo": starlark.MakeInt64(t.Foo),
"foo": starlark.MakeInt64(c.Foo),
})
return v, nil
}
Expand All @@ -200,7 +206,3 @@ func (c customType) Truth() starlark.Bool {
func (c customType) Hash() (uint32, error) {
return 0, fmt.Errorf("unhashable: %s", c.Type())
}

var _ Unmarshaler = (*customType)(nil)
var _ Marshaler = (*customType)(nil)
var _ starlark.Value = (*customType)(nil)

0 comments on commit 2acf8d8

Please sign in to comment.