From 7df55564a9e3f41163d4d8d127f8d65111920d5d Mon Sep 17 00:00:00 2001 From: omissis Date: Sat, 13 Aug 2022 12:55:35 +0200 Subject: [PATCH] chore: rewrite file.RuleBuilder tests --- README.md | 8 +- internal/arch/file/rule_all_test.go | 194 ------------- internal/arch/file/rule_one_test.go | 139 ---------- internal/arch/file/rule_set_test.go | 257 ------------------ internal/arch/file/rule_test.go | 66 +++++ internal/arch/file/test/all/Test1file | 1 + internal/arch/file/test/all/Test2file | 1 + internal/arch/file/test/all/Test3file | 1 + internal/arch/file/test/one/Testfile | 1 + internal/arch/file/test/set/Test1file | 1 + internal/arch/file/test/set/Test2file | 1 + internal/arch/file/test/set/Test3file | 1 + internal/arch/file/that/are_in_folder_test.go | 15 +- .../arch/file/that/test/project1/Dockerfile | 6 + .../arch/file/that/test/project1/Makefile | 4 + .../arch/file/that/test/project2/Dockerfile.1 | 6 + .../arch/file/that/test/project2/Dockerfile.2 | 6 + internal/arch/file/that/test/project3/baz.txt | 1 + .../arch/file/that/test/project3/quux.txt | 1 + 19 files changed, 108 insertions(+), 602 deletions(-) delete mode 100644 internal/arch/file/rule_all_test.go delete mode 100644 internal/arch/file/rule_one_test.go delete mode 100644 internal/arch/file/rule_set_test.go create mode 100644 internal/arch/file/test/all/Test1file create mode 100644 internal/arch/file/test/all/Test2file create mode 100644 internal/arch/file/test/all/Test3file create mode 100644 internal/arch/file/test/one/Testfile create mode 100644 internal/arch/file/test/set/Test1file create mode 100644 internal/arch/file/test/set/Test2file create mode 100644 internal/arch/file/test/set/Test3file create mode 100644 internal/arch/file/that/test/project1/Dockerfile create mode 100644 internal/arch/file/that/test/project1/Makefile create mode 100644 internal/arch/file/that/test/project2/Dockerfile.1 create mode 100644 internal/arch/file/that/test/project2/Dockerfile.2 create mode 100644 internal/arch/file/that/test/project3/baz.txt create mode 100644 internal/arch/file/that/test/project3/quux.txt diff --git a/README.md b/README.md index 5b60618..af904c3 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ if a set of files: - [x] names do not match a regex - [x] paths matching a glob pattern exist - [x] paths matching a glob pattern do not exist -- [ ] is gitignored -- [ ] is gitcrypted +- [x] is gitignored +- [x] is gitcrypted if all files that respect some conditions: - [x] start with a given suffix @@ -56,8 +56,8 @@ if all files that respect some conditions: - [x] names do not match a regex - [x] paths matching a glob pattern exist - [x] paths matching a glob pattern do not exist -- [ ] are gitignored -- [ ] are gitcrypted +- [x] are gitignored +- [x] are gitcrypted if a package: - [ ] depends on another package diff --git a/internal/arch/file/rule_all_test.go b/internal/arch/file/rule_all_test.go deleted file mode 100644 index 80a05b4..0000000 --- a/internal/arch/file/rule_all_test.go +++ /dev/null @@ -1,194 +0,0 @@ -package file_test - -import ( - "goarkitect/internal/arch/file" - fs "goarkitect/internal/arch/file/should" - ft "goarkitect/internal/arch/file/that" - "goarkitect/internal/arch/rule" - "os" - "path/filepath" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" -) - -func Test_It_Checks_All_Files_In_A_Folder_Start_With(t *testing.T) { - basePath, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - - testCases := []struct { - desc string - folder string - wantViolations []rule.Violation - }{ - { - desc: "check that all files in a folder start with the given prefix when they do", - folder: filepath.Join(basePath, "test/project2"), - wantViolations: nil, - }, - { - desc: "check that all files in a folder start with the given prefix when they don't", - folder: filepath.Join(basePath, "test/project"), - wantViolations: []rule.Violation{ - rule.NewViolation("file's name 'Makefile' does not start with 'Docker'"), - }, - }, - } - - for _, tC := range testCases { - t.Run(tC.desc, func(t *testing.T) { - vs, errs := file.All(). - That(ft.AreInFolder(tC.folder, false)). - Should(fs.StartWith("Docker")). - Because("testing reasons") - - if !cmp.Equal(vs, tC.wantViolations, cmp.AllowUnexported(rule.Violation{}), cmpopts.EquateEmpty()) { - t.Errorf("Expected %v, got %v", tC.wantViolations, vs) - } - - if errs != nil { - t.Errorf("Expected errs to be nil, got: %+v", errs) - } - }) - } -} - -func Test_It_Checks_All_Files_In_A_Folder_End_With(t *testing.T) { - basePath, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - - testCases := []struct { - desc string - folder string - wantViolations []rule.Violation - }{ - { - desc: "check that all files in a folder end with the given suffix when they do", - folder: filepath.Join(basePath, "test/project"), - wantViolations: nil, - }, - { - desc: "check that all files in a folder end with the given suffix when they don't", - folder: filepath.Join(basePath, "test/config"), - wantViolations: []rule.Violation{ - rule.NewViolation("file's name 'base.yml' does not end with 'file'"), - }, - }, - } - - for _, tC := range testCases { - t.Run(tC.desc, func(t *testing.T) { - vs, errs := file.All(). - That(ft.AreInFolder(tC.folder, false)). - Should(fs.EndWith("file")). - Because("testing reasons") - - if !cmp.Equal(vs, tC.wantViolations, cmp.AllowUnexported(rule.Violation{}), cmpopts.EquateEmpty()) { - t.Errorf("Expected %v, got %v", tC.wantViolations, vs) - } - - if errs != nil { - t.Errorf("Expected errs to be nil, got: %+v", errs) - } - }) - } -} - -func Test_It_Checks_All_Files_Names_In_A_Folder_Match_A_Regexp(t *testing.T) { - basePath, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - - testCases := []struct { - desc string - folder string - regexp string - wantViolations []rule.Violation - }{ - { - desc: "check that all files' names in a folder match a regex", - folder: filepath.Join(basePath, "test/project"), - regexp: "[a-zA-Z0-9]+", - wantViolations: nil, - }, - { - desc: "check that all files' names in a folder do not match a regex", - folder: filepath.Join(basePath, "test/project"), - regexp: "[0-9]+", - wantViolations: []rule.Violation{ - rule.NewViolation("file's name 'Dockerfile' does not match regex '[0-9]+'"), - rule.NewViolation("file's name 'Makefile' does not match regex '[0-9]+'"), - }, - }, - } - - for _, tC := range testCases { - t.Run(tC.desc, func(t *testing.T) { - vs, errs := file.All(). - That(ft.AreInFolder(tC.folder, false)). - Should(fs.MatchRegex(tC.regexp)). - Because("testing reasons") - - if !cmp.Equal(vs, tC.wantViolations, cmp.AllowUnexported(rule.Violation{}), cmpopts.EquateEmpty()) { - t.Errorf("Expected violations %v, got %v", tC.wantViolations, vs) - } - - if errs != nil { - t.Errorf("Expected errs to be nil, got: %+v", errs) - } - }) - } -} - -func Test_It_Checks_All_Files_Paths_In_A_Folder_Match_A_Glob_Pattern(t *testing.T) { - basePath, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - - testCases := []struct { - desc string - folder string - glob string - wantViolations []rule.Violation - }{ - { - desc: "check that all files' names in a folder match a glob pattern", - folder: filepath.Join(basePath, "test/project3"), - glob: "*/*/*.txt", - wantViolations: nil, - }, - { - desc: "check that all files' names in a folder do not match a glob pattern", - folder: filepath.Join(basePath, "test/project3"), - glob: "*/*/*.doc", - wantViolations: []rule.Violation{ - rule.NewViolation("file's path 'baz.txt' does not match glob pattern '*/*/*.doc'"), - rule.NewViolation("file's path 'quux.txt' does not match glob pattern '*/*/*.doc'"), - }, - }, - } - - for _, tC := range testCases { - t.Run(tC.desc, func(t *testing.T) { - vs, errs := file.All(). - That(ft.AreInFolder(tC.folder, false)). - Should(fs.MatchGlob(tC.glob, basePath)). - Because("testing reasons") - - if !cmp.Equal(vs, tC.wantViolations, cmp.AllowUnexported(rule.Violation{}), cmpopts.EquateEmpty()) { - t.Errorf("Expected violations %v, got %v", tC.wantViolations, vs) - } - - if errs != nil { - t.Errorf("Expected errs to be nil, got: %+v", errs) - } - }) - } -} diff --git a/internal/arch/file/rule_one_test.go b/internal/arch/file/rule_one_test.go deleted file mode 100644 index 1e6f38c..0000000 --- a/internal/arch/file/rule_one_test.go +++ /dev/null @@ -1,139 +0,0 @@ -package file_test - -import ( - "goarkitect/internal/arch/file" - fs "goarkitect/internal/arch/file/should" - "goarkitect/internal/arch/rule" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" -) - -func Test_It_Checks_A_File_Exists(t *testing.T) { - testCases := []struct { - desc string - filename string - wantViolations []rule.Violation - }{ - { - desc: "check that a file exists when it's actually there", - filename: "./test/project/Makefile", - wantViolations: nil, - }, - { - desc: "check that a file exists when it's not there", - filename: "./test/project/NotExistingFile", - wantViolations: []rule.Violation{ - rule.NewViolation("file 'NotExistingFile' does not exist"), - }, - }, - } - - for _, tC := range testCases { - t.Run(tC.desc, func(t *testing.T) { - vs, errs := file.One(tC.filename). - Should(fs.Exist()). - Because("testing reasons") - - if !cmp.Equal(vs, tC.wantViolations, cmp.AllowUnexported(rule.Violation{}), cmpopts.EquateEmpty()) { - t.Errorf("Expected %v, got %v", tC.wantViolations, vs) - } - - if errs != nil { - t.Errorf("Expected errs to be nil, got: %+v", errs) - } - }) - } -} - -func Test_It_Checks_A_File_Does_Not_Exist(t *testing.T) { - testCases := []struct { - desc string - filename string - wantViolations []rule.Violation - }{ - { - desc: "check that a file does not exist", - filename: "./test/project/NotExistingFile", - wantViolations: nil, - }, - { - desc: "check that a file does not exist when it's actually there", - filename: "./test/project/Makefile", - wantViolations: []rule.Violation{ - rule.NewViolation("file 'Makefile' does exist"), - }, - }, - } - - for _, tC := range testCases { - t.Run(tC.desc, func(t *testing.T) { - vs, errs := file.One(tC.filename). - Should(fs.Not(fs.Exist())). - Because("testing reasons") - - if !cmp.Equal(vs, tC.wantViolations, cmp.AllowUnexported(rule.Violation{}), cmpopts.EquateEmpty()) { - t.Errorf("Expected %v, got %v", tC.wantViolations, vs) - } - - if errs != nil { - t.Errorf("Expected errs to be nil, got: %+v", errs) - } - }) - } -} - -func Test_It_Checks_A_File_Name_Matches_A_Regexp(t *testing.T) { - testCases := []struct { - desc string - filename string - regexp string - wantViolations []rule.Violation - }{ - { - desc: "check that a file name matches a regex when it's actually there", - filename: "./test/project/Makefile", - regexp: "[a-zA-Z0-9]+", - wantViolations: nil, - }, - { - desc: "check that a file name matches a regex when it's not actually there", - filename: "./test/project/NotExistingFile", - regexp: "[a-zA-Z0-9]+", - wantViolations: nil, - }, - { - desc: "check that a file name does not match a regex when it's actually there", - filename: "./test/project/Makefile", - regexp: "[0-9]+", - wantViolations: []rule.Violation{ - rule.NewViolation("file's name 'Makefile' does not match regex '[0-9]+'"), - }, - }, - { - desc: "check that a file name does not match a regex when it's not actually there", - filename: "./test/project/NotExistingFile", - regexp: "[0-9]+", - wantViolations: []rule.Violation{ - rule.NewViolation("file's name 'NotExistingFile' does not match regex '[0-9]+'"), - }, - }, - } - - for _, tC := range testCases { - t.Run(tC.desc, func(t *testing.T) { - vs, errs := file.One(tC.filename). - Should(fs.MatchRegex(tC.regexp)). - Because("testing reasons") - - if !cmp.Equal(vs, tC.wantViolations, cmp.AllowUnexported(rule.Violation{}), cmpopts.EquateEmpty()) { - t.Errorf("Expected violations %v, got %v", tC.wantViolations, vs) - } - - if errs != nil { - t.Errorf("Expected errs to be nil, got: %+v", errs) - } - }) - } -} diff --git a/internal/arch/file/rule_set_test.go b/internal/arch/file/rule_set_test.go deleted file mode 100644 index 03b41ed..0000000 --- a/internal/arch/file/rule_set_test.go +++ /dev/null @@ -1,257 +0,0 @@ -package file_test - -import ( - "goarkitect/internal/arch/file" - fs "goarkitect/internal/arch/file/should" - "goarkitect/internal/arch/rule" - "os" - "path/filepath" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" -) - -func Test_It_Checks_A_Set_Of_Files_Exist(t *testing.T) { - basePath, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - - testCases := []struct { - desc string - filenames []string - wantViolations []rule.Violation - }{ - { - desc: "check that a set of files exists when it's actually there", - filenames: []string{ - filepath.Join(basePath, "test/project/Dockerfile"), - filepath.Join(basePath, "test/project/Makefile"), - }, - wantViolations: nil, - }, - { - desc: "check that a set of files exists when it's not there", - filenames: []string{ - filepath.Join(basePath, "test/project/Foofile"), - filepath.Join(basePath, "test/project/Barfile"), - }, - wantViolations: []rule.Violation{ - rule.NewViolation("file 'Foofile' does not exist"), - rule.NewViolation("file 'Barfile' does not exist"), - }, - }, - } - - for _, tC := range testCases { - t.Run(tC.desc, func(t *testing.T) { - vs, errs := file.Set(tC.filenames...). - Should(fs.Exist()). - Because("testing reasons") - - if !cmp.Equal(vs, tC.wantViolations, cmp.AllowUnexported(rule.Violation{}), cmpopts.EquateEmpty()) { - t.Errorf("Expected %v, got %v", tC.wantViolations, vs) - } - - if errs != nil { - t.Errorf("Expected errs to be nil, got: %+v", errs) - } - }) - } -} - -func Test_It_Checks_A_Set_Of_Files_Do_Not_Exist(t *testing.T) { - basePath, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - - testCases := []struct { - desc string - filenames []string - wantViolations []rule.Violation - }{ - { - desc: "check that a set of files does not exist when the files are not actually there", - filenames: []string{ - filepath.Join(basePath, "test/project/Foofile"), - filepath.Join(basePath, "test/project/Barfile"), - }, - wantViolations: nil, - }, - { - desc: "check that a set of files does not exist when the files are actually there", - filenames: []string{ - filepath.Join(basePath, "test/project/Dockerfile"), - filepath.Join(basePath, "test/project/Makefile"), - }, - wantViolations: []rule.Violation{ - rule.NewViolation("file 'Dockerfile' does exist"), - rule.NewViolation("file 'Makefile' does exist"), - }, - }, - } - - for _, tC := range testCases { - t.Run(tC.desc, func(t *testing.T) { - vs, errs := file.Set(tC.filenames...). - Should(fs.Not(fs.Exist())). - Because("testing reasons") - - if !cmp.Equal(vs, tC.wantViolations, cmp.AllowUnexported(rule.Violation{}), cmpopts.EquateEmpty()) { - t.Errorf("Expected %v, got %v", tC.wantViolations, vs) - } - - if errs != nil { - t.Errorf("Expected errs to be nil, got: %+v", errs) - } - }) - } -} - -func Test_It_Checks_A_Set_Of_Files_Names_Matches_A_Regexp(t *testing.T) { - basePath, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - - testCases := []struct { - desc string - filenames []string - regexp string - wantViolations []rule.Violation - }{ - { - desc: "check that a set of files' names match a regex when it's actually there", - filenames: []string{ - filepath.Join(basePath, "test/project/Dockerfile"), - filepath.Join(basePath, "test/project/Makefile"), - }, - regexp: "[a-zA-Z0-9]+", - wantViolations: nil, - }, - { - desc: "check that a set of files' names match a regex when it's not actually there", - filenames: []string{ - filepath.Join(basePath, "test/project/Foofile"), - filepath.Join(basePath, "test/project/Barfile"), - }, - regexp: "[a-zA-Z0-9]+", - wantViolations: nil, - }, - { - desc: "check that a set of files' names do not match a regex when it's actually there", - filenames: []string{ - filepath.Join(basePath, "test/project/Dockerfile"), - filepath.Join(basePath, "test/project/Makefile"), - }, - regexp: "[0-9]+", - wantViolations: []rule.Violation{ - rule.NewViolation("file's name 'Dockerfile' does not match regex '[0-9]+'"), - rule.NewViolation("file's name 'Makefile' does not match regex '[0-9]+'"), - }, - }, - { - desc: "check that a set of files' names do not match a regex when it's not actually there", - filenames: []string{ - filepath.Join(basePath, "test/project/Foofile"), - filepath.Join(basePath, "test/project/Barfile"), - }, - regexp: "[0-9]+", - wantViolations: []rule.Violation{ - rule.NewViolation("file's name 'Foofile' does not match regex '[0-9]+'"), - rule.NewViolation("file's name 'Barfile' does not match regex '[0-9]+'"), - }, - }, - } - - for _, tC := range testCases { - t.Run(tC.desc, func(t *testing.T) { - vs, errs := file.Set(tC.filenames...). - Should(fs.MatchRegex(tC.regexp)). - Because("testing reasons") - - if !cmp.Equal(vs, tC.wantViolations, cmp.AllowUnexported(rule.Violation{}), cmpopts.EquateEmpty()) { - t.Errorf("Expected violations %v, got %v", tC.wantViolations, vs) - } - - if errs != nil { - t.Errorf("Expected errs to be nil, got: %+v", errs) - } - }) - } -} - -func Test_It_Checks_A_Set_Of_Files_Names_Matches_A_Glob_Pattern(t *testing.T) { - basePath, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - - testCases := []struct { - desc string - filenames []string - glob string - wantViolations []rule.Violation - }{ - { - desc: "check that a set of files' names match a glob pattern when it's actually there", - filenames: []string{ - filepath.Join(basePath, "test/project3/baz.txt"), - filepath.Join(basePath, "test/project3/quux.txt"), - }, - glob: "*/*/*.txt", - wantViolations: nil, - }, - { - desc: "check that a set of files' names match a glob pattern when it's not actually there", - filenames: []string{ - filepath.Join(basePath, "test/project3/baz.doc"), - filepath.Join(basePath, "test/project3/quux.doc"), - }, - glob: "*/*/*.doc", - wantViolations: nil, - }, - { - desc: "check that a set of files' names do not match a glob pattern when it's actually there", - filenames: []string{ - filepath.Join(basePath, "test/project3/baz.txt"), - filepath.Join(basePath, "test/project3/quux.txt"), - }, - glob: "*/*/*.doc", - wantViolations: []rule.Violation{ - rule.NewViolation("file's path 'baz.txt' does not match glob pattern '*/*/*.doc'"), - rule.NewViolation("file's path 'quux.txt' does not match glob pattern '*/*/*.doc'"), - }, - }, - { - desc: "check that a set of files' names do not match a glob pattern when it's not actually there", - filenames: []string{ - filepath.Join(basePath, "test/project3/baz.doc"), - filepath.Join(basePath, "test/project3/quux.doc"), - }, - glob: "*/*/*.txt", - wantViolations: []rule.Violation{ - rule.NewViolation("file's path 'baz.doc' does not match glob pattern '*/*/*.txt'"), - rule.NewViolation("file's path 'quux.doc' does not match glob pattern '*/*/*.txt'"), - }, - }, - } - - for _, tC := range testCases { - t.Run(tC.desc, func(t *testing.T) { - vs, errs := file.Set(tC.filenames...). - Should(fs.MatchGlob(tC.glob, basePath)). - Because("testing reasons") - - if !cmp.Equal(vs, tC.wantViolations, cmp.AllowUnexported(rule.Violation{}), cmpopts.EquateEmpty()) { - t.Errorf("Expected violations %v, got %v", tC.wantViolations, vs) - } - - if errs != nil { - t.Errorf("Expected errs to be nil, got: %+v", errs) - } - }) - } -} diff --git a/internal/arch/file/rule_test.go b/internal/arch/file/rule_test.go index 896d6b9..017a2cb 100644 --- a/internal/arch/file/rule_test.go +++ b/internal/arch/file/rule_test.go @@ -2,9 +2,75 @@ package file_test import ( "goarkitect/internal/arch/file" + fe "goarkitect/internal/arch/file/except" + fs "goarkitect/internal/arch/file/should" + "goarkitect/internal/arch/rule" + "os" "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" ) +func Test_It_Checks_All_Conditions(t *testing.T) { + basePath, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + + testCases := []struct { + desc string + ruleBuilder rule.Builder + wantViolations []rule.Violation + }{ + { + desc: "check that a file matches all conditions", + ruleBuilder: file.One("./test/one/Testfile"), + wantViolations: nil, + }, + { + desc: "check that a set of files matches all conditions", + ruleBuilder: file.Set( + "./test/set/Test1file", + "./test/set/Test2file", + "./test/set/Test3file", + ), + wantViolations: nil, + }, + { + desc: "check that all files in folder except one match all conditions", + ruleBuilder: file.All().Except(fe.This("./test/set/Test3file")), + wantViolations: nil, + }, + } + + for _, tC := range testCases { + t.Run(tC.desc, func(t *testing.T) { + vs, errs := tC.ruleBuilder. + Should(fs.Not(fs.BeGitencrypted())). + Should(fs.Not(fs.BeGitignored())). + Should(fs.ContainValue([]byte("foo"))). + Should(fs.EndWith("file")). + Should(fs.Exist()). + Should(fs.HaveContentMatching([]byte("foo"), fs.IgnoreNewLinesAtTheEndOfFile{})). + Should(fs.HaveContentMatchingRegex("[0-9]+", fs.IgnoreNewLinesAtTheEndOfFile{})). + Should(fs.HavePermissions("-rwxr-xr-x")). + Should(fs.MatchGlob("test/one/*", basePath)). + Should(fs.MatchRegex("[A-z0-9]+")). + Should(fs.StartWith("Test")). + Because("I want to test all expressions together") + + if !cmp.Equal(vs, tC.wantViolations, cmp.AllowUnexported(rule.Violation{}), cmpopts.EquateEmpty()) { + t.Errorf("Expected %v, got %v", tC.wantViolations, vs) + } + + if errs != nil { + t.Errorf("Expected errs to be nil, got: %+v", errs) + } + }) + } +} + func Test_It_Adds_ErrRuleBuilderLocked_Only_Once(t *testing.T) { rb := file.NewRuleBuilder() diff --git a/internal/arch/file/test/all/Test1file b/internal/arch/file/test/all/Test1file new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/internal/arch/file/test/all/Test1file @@ -0,0 +1 @@ +foo diff --git a/internal/arch/file/test/all/Test2file b/internal/arch/file/test/all/Test2file new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/internal/arch/file/test/all/Test2file @@ -0,0 +1 @@ +foo diff --git a/internal/arch/file/test/all/Test3file b/internal/arch/file/test/all/Test3file new file mode 100644 index 0000000..5716ca5 --- /dev/null +++ b/internal/arch/file/test/all/Test3file @@ -0,0 +1 @@ +bar diff --git a/internal/arch/file/test/one/Testfile b/internal/arch/file/test/one/Testfile new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/internal/arch/file/test/one/Testfile @@ -0,0 +1 @@ +foo diff --git a/internal/arch/file/test/set/Test1file b/internal/arch/file/test/set/Test1file new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/internal/arch/file/test/set/Test1file @@ -0,0 +1 @@ +foo diff --git a/internal/arch/file/test/set/Test2file b/internal/arch/file/test/set/Test2file new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/internal/arch/file/test/set/Test2file @@ -0,0 +1 @@ +foo diff --git a/internal/arch/file/test/set/Test3file b/internal/arch/file/test/set/Test3file new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/internal/arch/file/test/set/Test3file @@ -0,0 +1 @@ +foo diff --git a/internal/arch/file/that/are_in_folder_test.go b/internal/arch/file/that/are_in_folder_test.go index 7abab10..70f6066 100644 --- a/internal/arch/file/that/are_in_folder_test.go +++ b/internal/arch/file/that/are_in_folder_test.go @@ -37,16 +37,15 @@ func Test_AreInFolder(t *testing.T) { { desc: "files in 'test' folder, recursively", ruleBuilder: file.All(), - folder: "../test", + folder: "./test", recursive: true, want: []string{ - "../test/config/base.yml", - "../test/project/Dockerfile", - "../test/project/Makefile", - "../test/project2/Dockerfile.1", - "../test/project2/Dockerfile.2", - "../test/project3/baz.txt", - "../test/project3/quux.txt", + "test/project1/Dockerfile", + "test/project1/Makefile", + "test/project2/Dockerfile.1", + "test/project2/Dockerfile.2", + "test/project3/baz.txt", + "test/project3/quux.txt", }, wantErrs: nil, }, diff --git a/internal/arch/file/that/test/project1/Dockerfile b/internal/arch/file/that/test/project1/Dockerfile new file mode 100644 index 0000000..ca77ed3 --- /dev/null +++ b/internal/arch/file/that/test/project1/Dockerfile @@ -0,0 +1,6 @@ +FROM alpine AS test + +RUN apk update +RUN apk add bash curl + +ENTRYPOINT /bin/bash diff --git a/internal/arch/file/that/test/project1/Makefile b/internal/arch/file/that/test/project1/Makefile new file mode 100644 index 0000000..9824069 --- /dev/null +++ b/internal/arch/file/that/test/project1/Makefile @@ -0,0 +1,4 @@ +.PHONY: cake + +cake: + echo "it is a lie." diff --git a/internal/arch/file/that/test/project2/Dockerfile.1 b/internal/arch/file/that/test/project2/Dockerfile.1 new file mode 100644 index 0000000..fbf041e --- /dev/null +++ b/internal/arch/file/that/test/project2/Dockerfile.1 @@ -0,0 +1,6 @@ +FROM golang:alpine AS test + +RUN apk update +RUN apk add bash curl + +ENTRYPOINT /bin/bash diff --git a/internal/arch/file/that/test/project2/Dockerfile.2 b/internal/arch/file/that/test/project2/Dockerfile.2 new file mode 100644 index 0000000..8b63bd8 --- /dev/null +++ b/internal/arch/file/that/test/project2/Dockerfile.2 @@ -0,0 +1,6 @@ +FROM node:alpine AS test + +RUN apk update +RUN apk add bash curl + +ENTRYPOINT /bin/bash diff --git a/internal/arch/file/that/test/project3/baz.txt b/internal/arch/file/that/test/project3/baz.txt new file mode 100644 index 0000000..2668907 --- /dev/null +++ b/internal/arch/file/that/test/project3/baz.txt @@ -0,0 +1 @@ +This is some baz content diff --git a/internal/arch/file/that/test/project3/quux.txt b/internal/arch/file/that/test/project3/quux.txt new file mode 100644 index 0000000..b3e336e --- /dev/null +++ b/internal/arch/file/that/test/project3/quux.txt @@ -0,0 +1 @@ +This is some quux content