Skip to content

Commit

Permalink
Resolve linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SBGoods committed Mar 5, 2024
1 parent bbaa513 commit 31cea02
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/check/directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

func TestNumberOfFilesCheck(t *testing.T) {
t.Parallel()
testCases := []struct {
Name string
Directories map[string][]string
Expand All @@ -31,7 +32,9 @@ func TestNumberOfFilesCheck(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()
got := NumberOfFilesCheck(testCase.Directories)

if got == nil && testCase.ExpectError {
Expand All @@ -46,6 +49,7 @@ func TestNumberOfFilesCheck(t *testing.T) {
}

func TestMixedDirectoriesCheck(t *testing.T) {
t.Parallel()
testCases := []struct {
Name string
BasePath string
Expand All @@ -63,7 +67,9 @@ func TestMixedDirectoriesCheck(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()
got := MixedDirectoriesCheck(testCase.BasePath)

if got == nil && testCase.ExpectError {
Expand Down
3 changes: 3 additions & 0 deletions internal/check/file_extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestTrimFileExtension(t *testing.T) {
t.Parallel()
testCases := []struct {
Name string
Path string
Expand Down Expand Up @@ -41,7 +42,9 @@ func TestTrimFileExtension(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()
got := TrimFileExtension(testCase.Path)
want := testCase.Expect

Expand Down
23 changes: 23 additions & 0 deletions internal/check/file_mismatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func TestFileHasResource(t *testing.T) {
t.Parallel()
testCases := []struct {
Name string
File string
Expand Down Expand Up @@ -39,7 +40,10 @@ func TestFileHasResource(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()

got := fileHasResource(testCase.Resources, "test", testCase.File)
want := testCase.Expect

Expand All @@ -51,6 +55,7 @@ func TestFileHasResource(t *testing.T) {
}

func TestFileResourceName(t *testing.T) {
t.Parallel()
testCases := []struct {
Name string
File string
Expand Down Expand Up @@ -79,7 +84,9 @@ func TestFileResourceName(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()
got := fileResourceName("test", testCase.File)
want := testCase.Expect

Expand All @@ -91,6 +98,7 @@ func TestFileResourceName(t *testing.T) {
}

func TestFileMismatchCheck(t *testing.T) {
t.Parallel()
testCases := []struct {
Name string
ResourceFiles fstest.MapFS
Expand Down Expand Up @@ -298,7 +306,10 @@ func TestFileMismatchCheck(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()

resourceFiles, _ := testCase.ResourceFiles.ReadDir(".")
functionFiles, _ := testCase.FunctionFiles.ReadDir(".")
testCase.Options.ResourceEntries = resourceFiles
Expand All @@ -317,6 +328,7 @@ func TestFileMismatchCheck(t *testing.T) {
}

func TestResourceHasFile(t *testing.T) {
t.Parallel()
testCases := []struct {
Name string
FS fstest.MapFS
Expand Down Expand Up @@ -344,7 +356,10 @@ func TestResourceHasFile(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()

files, _ := testCase.FS.ReadDir(".")

got := resourceHasFile(files, "test", testCase.ResourceName)
Expand All @@ -358,6 +373,7 @@ func TestResourceHasFile(t *testing.T) {
}

func TestFunctionHasFile(t *testing.T) {
t.Parallel()
testCases := []struct {
Name string
FS fstest.MapFS
Expand Down Expand Up @@ -385,7 +401,10 @@ func TestFunctionHasFile(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()

files, _ := testCase.FS.ReadDir(".")

got := functionHasFile(files, testCase.FunctionName)
Expand All @@ -399,6 +418,7 @@ func TestFunctionHasFile(t *testing.T) {
}

func TestResourceNames(t *testing.T) {
t.Parallel()
testCases := []struct {
Name string
Resources map[string]*tfjson.Schema
Expand All @@ -423,7 +443,10 @@ func TestResourceNames(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()

got := resourceNames(testCase.Resources)
want := testCase.Expect

Expand Down
8 changes: 8 additions & 0 deletions internal/check/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

func TestFileSizeCheck(t *testing.T) {
t.Parallel()
testCases := []struct {
Name string
Size int64
Expand All @@ -31,7 +32,10 @@ func TestFileSizeCheck(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()

file, err := os.CreateTemp(os.TempDir(), "TestFileSizeCheck")

if err != nil {
Expand All @@ -58,6 +62,7 @@ func TestFileSizeCheck(t *testing.T) {
}

func TestFullPath(t *testing.T) {
t.Parallel()
testCases := []struct {
Name string
FileOptions *FileOptions
Expand All @@ -81,7 +86,10 @@ func TestFullPath(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()

got := testCase.FileOptions.FullPath(testCase.Path)
want := testCase.Expect

Expand Down
4 changes: 4 additions & 0 deletions internal/check/frontmatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestFrontMatterCheck(t *testing.T) {
t.Parallel()
testCases := []struct {
Name string
Source string
Expand Down Expand Up @@ -149,7 +150,10 @@ subcategory: Example Subcategory
}

for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()

got := NewFrontMatterCheck(testCase.Options).Run([]byte(testCase.Source))

if got == nil && testCase.ExpectError {
Expand Down

0 comments on commit 31cea02

Please sign in to comment.