File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
+ "encoding/json"
4
5
"os"
5
- "strings"
6
6
"testing"
7
+
8
+ "github.com/humanlogio/humanlog/internal/pkg/config"
9
+ "github.com/stretchr/testify/require"
7
10
)
8
11
9
12
func TestApplyConfigFromConfigFile_when_one_of_skip_or_keep_is_given (t * testing.T ) {
10
13
11
- wd , _ := os .Getwd ()
12
- dirs := strings .Split (wd , "/" )
13
- root := strings .Join (dirs [:len (dirs )- 2 ], "/" )
14
- configFilePath := root + "/test/cases/00065-apply-config/config.json"
15
- t .Logf ("config file path: %v" , configFilePath )
14
+ cfg := config.Config {
15
+ Skip : ptr ([]string {"foo" , "bar" }),
16
+ }
17
+
18
+ dir := t .TempDir ()
19
+ f , err := os .CreateTemp (dir , "00065-apply-config.json" )
20
+ require .NoError (t , err )
21
+
22
+ err = json .NewEncoder (f ).Encode (cfg )
23
+ require .NoError (t , err )
24
+
25
+ err = f .Close ()
26
+ require .NoError (t , err )
16
27
17
- args := []string {"program-path" }
18
- args = append (args , "--config" , configFilePath )
28
+ args := []string {"program-path" , "--config" , f .Name ()}
19
29
20
30
app := newApp ()
21
31
if err := app .Run (args ); err != nil {
You can’t perform that action at this time.
0 commit comments