Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Castell committed Jul 4, 2019
1 parent de13171 commit 3ce0d74
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions dkron/store_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package dkron

import (
"io/ioutil"
"os"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestStore(t *testing.T) {
s, err := NewStore(nil, "test1.data")
dir, err := ioutil.TempDir("", "dkron-test")
require.NoError(t, err)
defer os.RemoveAll(dir)

s, err := NewStore(nil, dir)
require.NoError(t, err)
defer s.Shutdown()
if err != nil {
t.Fatal(err)
}

testJob := &Job{
Name: "test",
Expand Down Expand Up @@ -77,12 +82,6 @@ func TestStore(t *testing.T) {
}

func TestStore_GetLastExecutionGroup(t *testing.T) {
s, err := NewStore(nil, "test2.data")
defer s.Shutdown()
if err != nil {
t.Fatal(err)
}

// This can not use time.Now() because that will include monotonic information
// that will cause the unmarshalled execution to differ from our generated version
// See `go doc time`
Expand Down Expand Up @@ -192,6 +191,11 @@ func TestStore_GetLastExecutionGroup(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
dir, err := ioutil.TempDir("", "dkron-test")
require.NoError(t, err)
s, err := NewStore(nil, dir)
require.NoError(t, err)

for _, e := range tt.addExecutions {
s.SetExecution(e)
}
Expand All @@ -204,6 +208,11 @@ func TestStore_GetLastExecutionGroup(t *testing.T) {
for _, w := range tt.want {
assert.Contains(t, got, w)
}

err = s.Shutdown()
require.NoError(t, err)
err = os.RemoveAll(dir)
require.NoError(t, err)
})
}
}

0 comments on commit 3ce0d74

Please sign in to comment.