mirror of https://github.com/status-im/consul.git
fix TestStore_RegularTokens
This test was only passing because t.Parallel was causing every subtest to run with the last value in the iteration, which sets a value for all tokens. The test started to fail once t.Parallel was removed, but the same failure could have been produced by adding 'tt := tt' to the t.Run() func. These tests run in under 10ms, so there is no reason to use t.Parallel.
This commit is contained in:
parent
91d680b830
commit
a80de898ea
|
@ -7,8 +7,6 @@ import (
|
|||
)
|
||||
|
||||
func TestStore_RegularTokens(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
type tokens struct {
|
||||
userSource TokenSource
|
||||
user string
|
||||
|
@ -89,13 +87,22 @@ func TestStore_RegularTokens(t *testing.T) {
|
|||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
s := new(Store)
|
||||
if tt.set.user != "" {
|
||||
require.True(t, s.UpdateUserToken(tt.set.user, tt.set.userSource))
|
||||
}
|
||||
|
||||
if tt.set.agent != "" {
|
||||
require.True(t, s.UpdateAgentToken(tt.set.agent, tt.set.agentSource))
|
||||
}
|
||||
|
||||
if tt.set.repl != "" {
|
||||
require.True(t, s.UpdateReplicationToken(tt.set.repl, tt.set.replSource))
|
||||
}
|
||||
|
||||
if tt.set.master != "" {
|
||||
require.True(t, s.UpdateAgentMasterToken(tt.set.master, tt.set.masterSource))
|
||||
}
|
||||
|
||||
// If they don't change then they return false.
|
||||
require.False(t, s.UpdateUserToken(tt.set.user, tt.set.userSource))
|
||||
|
@ -128,7 +135,6 @@ func TestStore_RegularTokens(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStore_AgentMasterToken(t *testing.T) {
|
||||
t.Parallel()
|
||||
s := new(Store)
|
||||
|
||||
verify := func(want bool, toks ...string) {
|
||||
|
@ -152,7 +158,6 @@ func TestStore_AgentMasterToken(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStore_Notify(t *testing.T) {
|
||||
t.Parallel()
|
||||
s := new(Store)
|
||||
|
||||
newNotification := func(t *testing.T, s *Store, kind TokenKind) Notifier {
|
||||
|
|
Loading…
Reference in New Issue