-
Notifications
You must be signed in to change notification settings - Fork 3
/
teardown_test.go
51 lines (40 loc) · 1.07 KB
/
teardown_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package astra
import (
"github.com/stretchr/testify/require"
"os"
"testing"
)
func TestService_Teardown(t *testing.T) {
t.Run("tears down astra directory when cache is disabled and cli mode is none", func(t *testing.T) {
service := &Service{
CacheEnabled: false,
CLIMode: CLIModeNone,
}
err := service.Setup()
require.NoError(t, err)
stat, err := os.Stat(service.getAstraDirPath())
require.NoError(t, err)
require.NotNil(t, stat)
err = service.Teardown()
require.NoError(t, err)
stat, err = os.Stat(service.getAstraDirPath())
require.Error(t, err)
require.Nil(t, stat)
})
t.Run("leaves astra directory when cache is enabled", func(t *testing.T) {
service := &Service{
CacheEnabled: true,
CLIMode: CLIModeNone,
}
err := service.Setup()
require.NoError(t, err)
stat, err := os.Stat(service.getAstraDirPath())
require.NoError(t, err)
require.NotNil(t, stat)
err = service.Teardown()
require.NoError(t, err)
stat, err = os.Stat(service.getAstraDirPath())
require.NoError(t, err)
require.NotNil(t, stat)
})
}