deps: update set and test (#14680)

This PR updates go-set and shoenig/test, which introduced some breaking
API changes.
This commit is contained in:
Seth Hoenig
2022-09-26 08:28:03 -05:00
committed by GitHub
parent a34c241f62
commit 211ac8ec23
13 changed files with 33 additions and 30 deletions

View File

@@ -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) {

View File

@@ -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.
@@ -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
@@ -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.
@@ -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

4
go.mod
View File

@@ -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
@@ -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

8
go.sum
View File

@@ -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=
@@ -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=

View File

@@ -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 {

View File

@@ -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)
}
}

View File

@@ -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)
@@ -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) {

View File

@@ -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]

View File

@@ -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})
}

View File

@@ -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)
}

View File

@@ -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 {

View File

@@ -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),
@@ -137,5 +137,5 @@ func TestVaultConfig_Equals(t *testing.T) {
TLSServerName: "1",
}
must.NotEquals(t, c3, c4)
must.NotEqual(t, c3, c4)
}

View File

@@ -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
})
@@ -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
})
@@ -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()
@@ -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
})
@@ -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)
})
}