Skip to content

Commit

Permalink
fix: Removed tempDir to avoid windows bug
Browse files Browse the repository at this point in the history
  • Loading branch information
RamiAwar committed Dec 3, 2024
1 parent b4860e8 commit 756906a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 10 additions & 4 deletions snippet/snippet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ func createSnippetFile(t *testing.T, filename string, snippets *Snippets) {
}

func TestLoad(t *testing.T) {
tempDir := t.TempDir()
tempDir, _ := os.MkdirTemp("", "testdata")
defer os.RemoveAll(tempDir)
// Mock configuration
config.Conf.General.SnippetFile = filepath.Join(tempDir, "snippets.toml")

Expand Down Expand Up @@ -115,7 +116,8 @@ func TestLoad(t *testing.T) {
}

func TestLoadWithIncludeDirectories(t *testing.T) {
tempDir := t.TempDir()
tempDir, _ := os.MkdirTemp("", "testdata")
defer os.RemoveAll(tempDir)
includeDir := filepath.Join(tempDir, "include1")

// Mock configuration
Expand Down Expand Up @@ -162,7 +164,9 @@ func TestLoadWithIncludeDirectories(t *testing.T) {
}

func TestSave(t *testing.T) {
tempDir := t.TempDir()
tempDir, _ := os.MkdirTemp("", "testdata")
defer os.RemoveAll(tempDir)

// Mock configuration
config.Conf.General.SnippetFile = filepath.Join(tempDir, "snippets.toml")

Expand Down Expand Up @@ -206,7 +210,9 @@ func TestSave(t *testing.T) {
}

func TestSaveWithMultipleSnippetFiles(t *testing.T) {
tempDir := t.TempDir()
tempDir, _ := os.MkdirTemp("", "testdata")
defer os.RemoveAll(tempDir)

includeDir := filepath.Join(tempDir, "include1")

// Mock configuration
Expand Down
3 changes: 1 addition & 2 deletions snippet/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestTomlRegEx(t *testing.T) {

func TestGetFiles(t *testing.T) {
testDataPath, _ := os.MkdirTemp("", "testdata")
defer os.RemoveAll(testDataPath)

os.Create(filepath.Join(testDataPath, "01-snippet.toml"))
os.Create(filepath.Join(testDataPath, "02-unrelated.json"))
Expand All @@ -52,8 +53,6 @@ func TestGetFiles(t *testing.T) {
os.Create(filepath.Join(subdir, "05-snippet.toml"))
os.Create(filepath.Join(subdir, "06-unrelated.yaml"))

defer os.RemoveAll(testDataPath)

t.Run("success - returns list of toml files in a directory", func(t *testing.T) {
got := getFiles(testDataPath)
want := []string{
Expand Down

0 comments on commit 756906a

Please sign in to comment.