change failing test to use subtests
This commit is contained in:
parent
a5cb530571
commit
7715bc8423
|
@ -1,6 +1,7 @@
|
||||||
package state
|
package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -77,29 +78,31 @@ func TestCacheState_RefreshState(t *testing.T) {
|
||||||
expected: CacheRefreshLocalNewer,
|
expected: CacheRefreshLocalNewer,
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
cache := testLocalState(t)
|
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
||||||
durable := testLocalState(t)
|
cache := testLocalState(t)
|
||||||
defer os.Remove(cache.Path)
|
durable := testLocalState(t)
|
||||||
defer os.Remove(durable.Path)
|
defer os.Remove(cache.Path)
|
||||||
|
defer os.Remove(durable.Path)
|
||||||
|
|
||||||
cs := &CacheState{
|
cs := &CacheState{
|
||||||
Cache: cache,
|
Cache: cache,
|
||||||
Durable: durable,
|
Durable: durable,
|
||||||
}
|
}
|
||||||
|
|
||||||
state := cache.State()
|
state := cache.State()
|
||||||
state.Modules = test.cacheModules
|
state.Modules = test.cacheModules
|
||||||
if err := cs.WriteState(state); err != nil {
|
if err := cs.WriteState(state); err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cs.RefreshState(); err != nil {
|
if err := cs.RefreshState(); err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cs.RefreshResult() != test.expected {
|
if cs.RefreshResult() != test.expected {
|
||||||
t.Fatalf("bad %d: %v", i, cs.RefreshResult())
|
t.Fatalf("bad %d: %v", i, cs.RefreshResult())
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue