Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gandarez committed Dec 18, 2023
1 parent 63781d4 commit 9e75bfb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [opened, reopened, ready_for_review, synchronize]
push:
branches: [develop, release]
tags-ignore: "**"
tags-ignore: ["**"]

env:
GO_VERSION_FILE: "go.mod"
Expand Down
4 changes: 2 additions & 2 deletions pkg/project/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ func (f File) Detect() (Result, bool, error) {
Folder: filepath.Dir(fp),
}

result.Project = filepath.Base(filepath.Dir(fp))

if len(lines) > 0 {
result.Project = strings.TrimSpace(lines[0])
} else {
result.Project = filepath.Base(filepath.Dir(fp))
}

if len(lines) > 1 {
Expand Down
9 changes: 4 additions & 5 deletions pkg/project/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,10 @@ func TestDetect_EmptyFileDetected(t *testing.T) {
err = os.Mkdir(filepath.Join(tmpDir, "wakatime-cli"), os.FileMode(int(0700)))
require.NoError(t, err)

copyFile(
t,
"testdata/wakatime-project-empty",
filepath.Join(tmpDir, "wakatime-cli", ".wakatime-project"),
)
tmpWakatimeProjectEmpty, err := os.Create(filepath.Join(tmpDir, "wakatime-cli", ".wakatime-project"))
require.NoError(t, err)

defer tmpWakatimeProjectEmpty.Close()

copyFile(
t,
Expand Down
Empty file.

0 comments on commit 9e75bfb

Please sign in to comment.