-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain_test.go
More file actions
57 lines (48 loc) · 1.25 KB
/
main_test.go
File metadata and controls
57 lines (48 loc) · 1.25 KB
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
52
53
54
55
56
57
package main_test
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/BytecodeAgency/import-boundary-checker/logging"
"github.com/BytecodeAgency/import-boundary-checker/runner"
"github.com/stretchr/testify/assert"
)
func TestEndToEnd(t *testing.T) {
rootDir, err := os.Getwd()
assert.NoError(t, err)
tests := []struct {
dir string
shouldErr bool
}{
{"go-invalid-1", true},
{"go-invalid-2", true},
{"go-invalid-3", true},
{"go-invalid-4", true},
{"go-invalid-5", true},
{"go-valid-1", false},
{"go-valid-2", false},
{"go-valid-3", false},
}
for _, test := range tests {
// cd into test dir
err := os.Chdir("./examples/" + test.dir)
assert.NoError(t, err)
// Load config file
abs, err := filepath.Abs(".importrules")
assert.NoError(t, err)
configFile, err := ioutil.ReadFile(abs)
assert.NoError(t, err)
config := string(configFile)
// Create and run runner
// TODO: Add automated end-to-end tests
logger := logging.Logger{Verbose: false}
r := runner.New(config, &logger)
got := r.Run()
// Check if we got what we expected
assert.Equalf(t, test.shouldErr, got, "example directory %s", test.dir)
// Change back to parent directory
err = os.Chdir(rootDir)
assert.NoError(t, err)
}
}