Skip to content

Commit 51c8ca0

Browse files
committed
feat: add handler test and ci.sh
1 parent 0f3eb40 commit 51c8ca0

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

ci.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
22

33
golangci-lint run --fix
4+
go test ./... -v
45
go fmt ./...

handler/handler_test.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package handler
22

33
import (
44
"errors"
5-
"fmt"
65
"os"
76
"path/filepath"
87
"testing"
@@ -15,13 +14,17 @@ func TestParseConfig(t *testing.T) {
1514
projectDir1 := filepath.Join(tmpRoot, project1Name)
1615
projectDir2 := filepath.Join(tmpRoot, project2Name)
1716
projects := []string{projectDir1, projectDir2}
18-
os.Mkdir(projectDir1, 0755)
19-
os.Mkdir(projectDir2, 0755)
17+
if err := os.Mkdir(projectDir1, 0755); err != nil {
18+
t.Errorf("failed to make project1 directory")
19+
}
20+
if err := os.Mkdir(projectDir2, 0755); err != nil {
21+
t.Errorf("failed to make project2 directory")
22+
}
2023

21-
configContent := fmt.Sprintf("default=%s", tmpRoot)
24+
configContent := "default=" + tmpRoot
2225

2326
tmpConfigFile := filepath.Join(tmpRoot, ".tmux-sessionizer")
24-
if err := os.WriteFile(tmpConfigFile, []byte(configContent), 0644); err != nil {
27+
if err := os.WriteFile(tmpConfigFile, []byte(configContent), 0600); err != nil {
2528
t.Errorf("failed to write config file: %v", err)
2629
}
2730

@@ -73,7 +76,6 @@ func TestExpandPath(t *testing.T) {
7376
},
7477
}
7578
for _, tt := range tests {
76-
tt := tt
7779
t.Run(tt.name, func(t *testing.T) {
7880
t.Parallel()
7981
sh := SessionHandler{}

0 commit comments

Comments
 (0)