Skip to content

Commit

Permalink
code review changes (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
pastuxso committed Nov 7, 2023
1 parent 3ab87c0 commit 0d1ea99
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ LDFLAGS := -s -w \
-X 'github.com/stateful/runme/internal/version.BuildVersion=$(subst v,,$(VERSION))' \
-X 'github.com/stateful/runme/internal/version.Commit=$(GIT_SHA)'

ifeq ($(RUNME_EXT_BASE),)
RUNME_EXT_BASE := "../vscode-runme"
endif

.PHONY: build
build:
go build -o runme -ldflags="$(LDFLAGS)" main.go
Expand Down
10 changes: 6 additions & 4 deletions internal/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"github.com/stretchr/testify/assert"
)

func TestGetMinorVersion(t *testing.T) {
// Test cases
func TestBaseVersion(t *testing.T) {
tests := []struct {
name string
buildVersion string
Expand All @@ -33,14 +32,17 @@ func TestGetMinorVersion(t *testing.T) {
buildVersion: "0.0.0",
expectedMinor: "0.0",
},
{
name: "invalid semver",
buildVersion: "1.2.beta",
expectedMinor: "unknown",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
BuildVersion = tt.buildVersion

baseVersion := BaseVersion()

assert.Equal(t, tt.expectedMinor, baseVersion)
})
}
Expand Down
4 changes: 2 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ func TestSkipPromptsWithinAPty(t *testing.T) {

expected := "The content of ENV is <insert-env-here>"
current := buf.String()
current = RemoveAnsiCodes(current)
current = removeAnsiCodes(current)
current = strings.TrimSpace(current)

assert.Equal(t, expected, current, "Output does not match")
}

func RemoveAnsiCodes(str string) string {
func removeAnsiCodes(str string) string {
re := regexp.MustCompile(`\x1b\[.*?[a-zA-Z]|\x1b\].*?\x1b\\`)
return re.ReplaceAllString(str, "")
}

0 comments on commit 0d1ea99

Please sign in to comment.