Skip to content

Commit

Permalink
deps: update set and test
Browse files Browse the repository at this point in the history
This PR updates go-set and shoenig/test, which introduced some breaking
API changes.
  • Loading branch information
shoenig committed Sep 24, 2022
1 parent a34c241 commit 17f987c
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion client/serviceregistration/checks/checkstore/shim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestShim_Difference(t *testing.T) {

ids := []structs.CheckID{"id1", "id2", "id3"}
unwanted := s.Difference("alloc1", ids)
must.Empty(t, unwanted)
must.SliceEmpty(t, unwanted)
})

t.Run("empty unwanted", func(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions client/serviceregistration/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ func TestCheckWatcher_Healthy(t *testing.T) {
cw.Run(ctx)

// Ensure restart was never called
must.Empty(t, restarter1.restarts, must.Sprint("expected check 1 to not be restarted"))
must.Empty(t, restarter2.restarts, must.Sprint("expected check 2 to not be restarted"))
must.SliceEmpty(t, restarter1.restarts, must.Sprint("expected check 1 to not be restarted"))
must.SliceEmpty(t, restarter2.restarts, must.Sprint("expected check 2 to not be restarted"))
}

// TestCheckWatcher_Unhealthy asserts unhealthy tasks are restarted exactly once.
Expand Down Expand Up @@ -260,7 +260,7 @@ func TestCheckWatcher_HealthyWarning(t *testing.T) {
cw.Run(ctx)

// Ensure restart was never called on check 1
must.Empty(t, restarter1.restarts, must.Sprint("expected check 1 to not be restarted"))
must.SliceEmpty(t, restarter1.restarts, must.Sprint("expected check 1 to not be restarted"))
}

// TestCheckWatcher_Flapping asserts checks that flap from healthy to unhealthy
Expand Down Expand Up @@ -288,7 +288,7 @@ func TestCheckWatcher_Flapping(t *testing.T) {
cw.Run(ctx)

// Ensure restart was never called on check 1
must.Empty(t, restarter1.restarts, must.Sprint("expected check 1 to not be restarted"))
must.SliceEmpty(t, restarter1.restarts, must.Sprint("expected check 1 to not be restarted"))
}

// TestCheckWatcher_Unwatch asserts unwatching checks prevents restarts.
Expand All @@ -314,7 +314,7 @@ func TestCheckWatcher_Unwatch(t *testing.T) {
cw.Run(ctx)

// Ensure restart was never called on check 1
must.Empty(t, restarter1.restarts, must.Sprint("expected check 1 to not be restarted"))
must.SliceEmpty(t, restarter1.restarts, must.Sprint("expected check 1 to not be restarted"))
}

// TestCheckWatcher_MultipleChecks asserts that when there are multiple checks
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ require (
github.com/hashicorp/go-plugin v1.4.3
github.com/hashicorp/go-secure-stdlib/listenerutil v0.1.4
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2
github.com/hashicorp/go-set v0.1.4
github.com/hashicorp/go-set v0.1.6
github.com/hashicorp/go-sockaddr v1.0.2
github.com/hashicorp/go-syslog v1.0.0
github.com/hashicorp/go-uuid v1.0.2
Expand Down Expand Up @@ -110,7 +110,7 @@ require (
github.com/ryanuber/go-glob v1.0.0
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529
github.com/shirou/gopsutil/v3 v3.22.7
github.com/shoenig/test v0.3.1
github.com/shoenig/test v0.4.0
github.com/skratchdot/open-golang v0.0.0-20160302144031-75fb7ed4208c
github.com/stretchr/testify v1.8.0
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,8 @@ github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 h1:kes8mmyCpxJsI7FTwtzRqEy9
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2/go.mod h1:Gou2R9+il93BqX25LAKCLuM+y9U2T4hlwvT1yprcna4=
github.com/hashicorp/go-secure-stdlib/tlsutil v0.1.1 h1:Yc026VyMyIpq1UWRnakHRG01U8fJm+nEfEmjoAb00n8=
github.com/hashicorp/go-secure-stdlib/tlsutil v0.1.1/go.mod h1:l8slYwnJA26yBz+ErHpp2IRCLr0vuOMGBORIz4rRiAs=
github.com/hashicorp/go-set v0.1.4 h1:LADVZzgPFLNI20TII1l75bnBI0LTnxpoCOPNjozNpi8=
github.com/hashicorp/go-set v0.1.4/go.mod h1:XFMEKCP3rGoZUBvdYwC9k2YVDj8PsMU/B0ITuYkl8IA=
github.com/hashicorp/go-set v0.1.6 h1:fj/JG5B97sAOd9OQN4GL880yCE384fz3asNDpGbxkPo=
github.com/hashicorp/go-set v0.1.6/go.mod h1:ELvMcE+1mRHYPVgTFSQiecObIwZRxY5Q11EhbtmM5KQ=
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc=
github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A=
Expand Down Expand Up @@ -1152,8 +1152,8 @@ github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shirou/gopsutil/v3 v3.22.7 h1:flKnuCMfUUrO+oAvwAd6GKZgnPzr098VA/UJ14nhJd4=
github.com/shirou/gopsutil/v3 v3.22.7/go.mod h1:s648gW4IywYzUfE/KjXxUsqrqx/T2xO5VqOXxONeRfI=
github.com/shoenig/test v0.3.1 h1:dhGZztS6nQuvJ0o0RtUiQHaEO4hhArh/WmWwik3Ols0=
github.com/shoenig/test v0.3.1/go.mod h1:xYtyGBC5Q3kzCNyJg/SjgNpfAa2kvmgA0i5+lQso8x0=
github.com/shoenig/test v0.4.0 h1:3X4xG/Chx7mzi0h71Sm6Vo38q0EYaQIBZpYFRcA1HVM=
github.com/shoenig/test v0.4.0/go.mod h1:xYtyGBC5Q3kzCNyJg/SjgNpfAa2kvmgA0i5+lQso8x0=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
Expand Down
2 changes: 1 addition & 1 deletion helper/boltdd/boltdd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func TestBucket_DedupeWrites(t *testing.T) {

// Assert there was at least 1 write
origWrites := db.BoltDB().Stats().TxStats.Write
must.Greater(t, origWrites, 0)
must.Positive(t, origWrites)

// Write the same values again and expect no new writes
must.NoError(t, db.Update(func(tx *Tx) error {
Expand Down
4 changes: 2 additions & 2 deletions helper/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestCluster_RandomStagger(t *testing.T) {

for _, tc := range cases {
result := RandomStagger(tc.input)
must.GreaterEq(t, result, 0)
must.LessEq(t, result, abs(tc.input))
must.GreaterEq(t, 0, result)
must.LessEq(t, abs(tc.input), result)
}
}
4 changes: 2 additions & 2 deletions helper/funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestIsSubset(t *testing.T) {

sub, offending := IsSubset(l, l[:1])
must.True(t, sub)
must.EmptySlice(t, offending)
must.SliceEmpty(t, offending)

sub, offending = IsSubset(l, s)
must.False(t, sub)
Expand All @@ -77,7 +77,7 @@ func TestIsDisjoint(t *testing.T) {
b := []string{"d", "f"}
dis, offending := IsDisjoint(a, b)
must.True(t, dis)
must.EmptySlice(t, offending)
must.SliceEmpty(t, offending)
})

t.Run("no", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion nomad/acl_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ func TestACLEndpoint_UpsertTokens(t *testing.T) {
}
var resp structs.ACLTokenUpsertResponse
require.NoError(t, msgpackrpc.CallWithCodec(codec, structs.ACLUpsertTokensRPCMethod, req, &resp))
must.Greater(t, resp.Index, 0)
must.Positive(t, resp.Index)

// Get the token out from the response.
created := resp.Tokens[0]
Expand Down
4 changes: 1 addition & 3 deletions nomad/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,5 @@ func TestResolveClaims(t *testing.T) {
policies, err := srv.resolvePoliciesForClaims(claims)
must.NoError(t, err)
must.Len(t, 3, policies)
must.Contains(t, policies, policy1)
must.Contains(t, policies, policy2)
must.Contains(t, policies, policy3)
must.SliceContainsAll(t, policies, []*structs.ACLPolicy{policy1, policy2, policy3})
}
2 changes: 1 addition & 1 deletion nomad/service_registration_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ func TestServiceRegistration_chooseErr(t *testing.T) {
sr := (*ServiceRegistration)(nil)
try := func(input []*structs.ServiceRegistration, parameter string) {
result, err := sr.choose(input, parameter)
must.Empty(t, result)
must.SliceEmpty(t, result)
must.ErrorIs(t, err, structs.ErrMalformedChooseParameter)
}

Expand Down
5 changes: 5 additions & 0 deletions nomad/structs/config/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ func (c *VaultConfig) Copy() *VaultConfig {
return nc
}

// Equal is a rename of Equals.
func (c *VaultConfig) Equal(b *VaultConfig) bool {
return c.Equals(b)
}

// Equals compares two Vault configurations and returns a boolean indicating
// if they are equal.
func (c *VaultConfig) Equals(b *VaultConfig) bool {
Expand Down
4 changes: 2 additions & 2 deletions nomad/structs/config/vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestVaultConfig_Equals(t *testing.T) {
TLSServerName: "1",
}

must.Equals(t, c1, c2)
must.Equal(t, c1, c2)

c3 := &VaultConfig{
Enabled: pointer.Of(true),
Expand Down Expand Up @@ -137,5 +137,5 @@ func TestVaultConfig_Equals(t *testing.T) {
TLSServerName: "1",
}

must.NotEquals(t, c3, c4)
must.NotEqual(t, c3, c4)
}
12 changes: 6 additions & 6 deletions nomad/variables_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func TestVariablesEndpoint_Apply_ACL(t *testing.T) {

must.NoError(t, err)
must.Eq(t, structs.VarOpResultOk, applyResp.Result)
must.Equals(t, sv1.Items, applyResp.Output.Items)
must.Eq(t, sv1.Items, applyResp.Output.Items)

svHold = applyResp.Output
})
Expand All @@ -353,7 +353,7 @@ func TestVariablesEndpoint_Apply_ACL(t *testing.T) {

must.NoError(t, err)
must.Eq(t, structs.VarOpResultOk, applyResp.Result)
must.Equals(t, sv.Items, applyResp.Output.Items)
must.Eq(t, sv.Items, applyResp.Output.Items)

svHold = applyResp.Output
})
Expand All @@ -380,8 +380,8 @@ func TestVariablesEndpoint_Apply_ACL(t *testing.T) {

must.NoError(t, err)
must.Eq(t, structs.VarOpResultConflict, applyResp.Result)
must.Equals(t, svHold.VariableMetadata, applyResp.Conflict.VariableMetadata)
must.Equals(t, svHold.Items, applyResp.Conflict.Items)
must.Eq(t, svHold.VariableMetadata, applyResp.Conflict.VariableMetadata)
must.Eq(t, svHold.Items, applyResp.Conflict.Items)
})

sv3 := mock.Variable()
Expand All @@ -404,7 +404,7 @@ func TestVariablesEndpoint_Apply_ACL(t *testing.T) {

must.NoError(t, err)
must.Eq(t, structs.VarOpResultOk, applyResp.Result)
must.Equals(t, sv3.Items, applyResp.Output.Items)
must.Eq(t, sv3.Items, applyResp.Output.Items)
svHold = applyResp.Output
})

Expand Down Expand Up @@ -449,7 +449,7 @@ func TestVariablesEndpoint_Apply_ACL(t *testing.T) {

must.NoError(t, err)
must.Eq(t, structs.VarOpResultOk, applyResp.Result)
must.Equals(t, sv.Items, applyResp.Output.Items)
must.Eq(t, sv.Items, applyResp.Output.Items)
})
}

Expand Down

0 comments on commit 17f987c

Please sign in to comment.