generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: watch for changes in replace paths
- Loading branch information
1 parent
4edee31
commit 08644bf
Showing
8 changed files
with
233 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package buildengine | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/alecthomas/assert/v2" | ||
) | ||
|
||
func TestComputeRootDirs(t *testing.T) { | ||
dir := t.TempDir() | ||
libDir := filepath.Join(dir, "libs", "test") | ||
|
||
err := os.MkdirAll(libDir, 0700) | ||
assert.NoError(t, err) | ||
|
||
tests := []struct { | ||
name string | ||
baseDir string | ||
patterns []string | ||
roots []string | ||
}{ | ||
{ | ||
name: "Simple Patterns", | ||
baseDir: filepath.Join(dir, "modules", "test"), | ||
patterns: []string{ | ||
"**/*.go", | ||
"go.mod", | ||
"go.sum", | ||
}, | ||
roots: []string{filepath.Join(dir, "modules", "test")}, | ||
}, | ||
{ | ||
name: "Upward Traversal", | ||
baseDir: filepath.Join(dir, "modules", "test"), | ||
patterns: []string{ | ||
"../../libs/test/**/*.go", | ||
}, | ||
roots: []string{ | ||
filepath.Join(dir, "modules", "test"), | ||
filepath.Join(dir, "libs", "test"), | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
roots := computeRootDirs(tt.baseDir, tt.patterns) | ||
assert.Compare(t, roots, tt.roots) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package moduleconfig | ||
|
||
import ( | ||
"path/filepath" | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestParseImportsFromTestData(t *testing.T) { | ||
testFilePath := filepath.Join("testdata", "imports.go") | ||
expectedImports := []string{"fmt", "os"} | ||
imports, err := parseImports(testFilePath) | ||
if err != nil { | ||
t.Fatalf("Failed to parse imports: %v", err) | ||
} | ||
|
||
if !reflect.DeepEqual(imports, expectedImports) { | ||
t.Errorf("parseImports() got = %v, want %v", imports, expectedImports) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func main() { | ||
fmt.Println("Hello, world!") | ||
os.Exit(0) | ||
} |