Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move assert.go, fail.go to separate assertmodule #87

Merged
merged 4 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ go_library(
importpath = "github.com/stripe/skycfg",
visibility = ["//visibility:public"],
deps = [
"//go/assertmodule",
"//go/hashmodule",
"//go/protomodule",
"//go/urlmodule",
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ Dmitry Ilyevsky <ilyevsky@gmail.com> # GM Cruise LLC
Isaac Diamond <idiamond@stripe.com>
John Millikin <jmillikin@stripe.com>
Matt Moriarity <mmoriarity@stripe.com>
Seena Burns <seena@stripe.com>

# Please alphabetize new entries.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/stripe/skycfg

go 1.16

require (
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.4.1
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
Expand All @@ -18,6 +21,8 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQL
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
go.starlark.net v0.0.0-20201204201740-42d4f566359b h1:yHUzJ1WfcdR1oOafytJ6K1/ntYwnEIXICNVzHb+FzbA=
go.starlark.net v0.0.0-20201204201740-42d4f566359b/go.mod h1:5YFcFnRptTN+41758c2bMPiqpGg4zBfYji1IQz8wNFk=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642 h1:B6caxRw+hozq68X2MY7jEpZh/cr4/aHLv9xU8Kkadrw=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
30 changes: 30 additions & 0 deletions go/assertmodule/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "assertmodule",
srcs = [
"assert.go",
"fail.go",
],
importpath = "github.com/stripe/skycfg/go/assertmodule",
visibility = ["//visibility:public"],
deps = [
"@net_starlark_go//starlark",
"@net_starlark_go//starlarkstruct",
"@net_starlark_go//syntax",
],
)

go_test(
name = "assertmodule_test",
size = "small",
srcs = [
"assert_test.go",
],
embed = [":assertmodule"],
deps = [
"@net_starlark_go//starlark",
"@net_starlark_go//starlarkstruct",
"@net_starlark_go//syntax",
],
)
4 changes: 2 additions & 2 deletions internal/go/skycfg/assert.go → go/assertmodule/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//
// SPDX-License-Identifier: Apache-2.0

package skycfg
package assertmodule

import (
"fmt"
Expand Down Expand Up @@ -89,7 +89,7 @@ type TestContext struct {
Failures []error
}

var _ starlark.HasAttrs = (*Module)(nil)
var _ starlark.HasAttrs = (*TestContext)(nil)
var _ starlark.Value = (*TestContext)(nil)
var _ starlark.Callable = (*TestContext)(nil)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
//
// SPDX-License-Identifier: Apache-2.0

package skycfg
package assertmodule

import (
"fmt"
"strings"
"testing"

"go.starlark.net/starlark"
"go.starlark.net/starlarkstruct"
"go.starlark.net/syntax"
)

Expand Down Expand Up @@ -338,9 +339,9 @@ func evalAndReportResults(t *testing.T, cmd string, testCase assertTestCase) {
assertModule := AssertModule()

// set it up like it would be used, off a param
testCtx := &Module{
testCtx := &starlarkstruct.Module{
Name: "skycfg_test_ctx",
Attrs: starlark.StringDict(map[string]starlark.Value{
Members: starlark.StringDict(map[string]starlark.Value{
"assert": assertModule,
}),
}
Expand Down
2 changes: 1 addition & 1 deletion internal/go/skycfg/fail.go → go/assertmodule/fail.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package skycfg
package assertmodule

import (
"fmt"
Expand Down
3 changes: 0 additions & 3 deletions internal/go/skycfg/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "skycfg",
srcs = [
"assert.go",
"fail.go",
"module.go",
"proto_api.go",
"proto_enum.go",
Expand Down Expand Up @@ -34,7 +32,6 @@ go_test(
name = "skycfg_test",
size = "small",
srcs = [
"assert_test.go",
"proto_test.go",
"skycfg_test.go",
],
Expand Down
5 changes: 3 additions & 2 deletions skycfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"go.starlark.net/starlarkstruct"
"google.golang.org/protobuf/reflect/protoregistry"

"github.com/stripe/skycfg/go/assertmodule"
"github.com/stripe/skycfg/go/hashmodule"
"github.com/stripe/skycfg/go/protomodule"
"github.com/stripe/skycfg/go/urlmodule"
Expand Down Expand Up @@ -185,7 +186,7 @@ func WithProtoRegistry(r unstableProtoRegistry) LoadOption {
// * url - utility package for encoding URL query string.
func UnstablePredeclaredModules(r unstableProtoRegistry) starlark.StringDict {
return starlark.StringDict{
"fail": impl.Fail,
"fail": assertmodule.Fail,
"hash": hashmodule.NewModule(),
"json": starlarkjson.Module,
"proto": UnstableProtoModule(r),
Expand Down Expand Up @@ -443,7 +444,7 @@ func (t *Test) Run(ctx context.Context) (*TestResult, error) {
}
thread.SetLocal("context", ctx)

assertModule := impl.AssertModule()
assertModule := assertmodule.AssertModule()
testCtx := &impl.Module{
Name: "skycfg_test_ctx",
Attrs: starlark.StringDict(map[string]starlark.Value{
Expand Down