Skip to content

Commit

Permalink
fix(cli): Update version number from 0.2.0 to 0.3.0
Browse files Browse the repository at this point in the history
The version number has been incremented to reflect the new release.
  • Loading branch information
tab committed Oct 16, 2024
1 parent 51226c1 commit 4b8d797
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 51 deletions.
3 changes: 1 addition & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ func main() {
client := git.NewGitClient()
model := gpt.NewGPTModel()
reader := func() (string, error) {
reader := bufio.NewReader(os.Stdin)
input, err := reader.ReadString('\n')
input, err := bufio.NewReader(os.Stdin).ReadString('\n')
return strings.TrimSpace(input), err
}
options := commands.GenerateOptions{Ctx: ctx, Client: client, Model: model}
Expand Down
94 changes: 47 additions & 47 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
package main

import (
"bytes"
"io"
"os"
"testing"
"bytes"
"io"
"os"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
)

func TestMainRun(t *testing.T) {
origArgs := os.Args
defer func() { os.Args = origArgs }()

tests := []struct {
name string
args []string
output string
}{
{
name: "Help command",
args: []string{"--help"},
output: "Usage:",
},
{
name: "Version command",
args: []string{"--version"},
output: "cmt 0.2.0\n",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
os.Args = append([]string{"cmd"}, tt.args...)

r, w, _ := os.Pipe()
origStdout := os.Stdout
os.Stdout = w
defer func() { os.Stdout = origStdout }()

main()

w.Close()
var buf bytes.Buffer
_, err := io.Copy(&buf, r)
if err != nil {
return
}
result := buf.String()

assert.Contains(t, result, tt.output)
})
}
origArgs := os.Args
defer func() { os.Args = origArgs }()

tests := []struct {
name string
args []string
output string
}{
{
name: "Help command",
args: []string{"--help"},
output: "Usage:",
},
{
name: "Version command",
args: []string{"--version"},
output: "cmt 0.3.0\n",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
os.Args = append([]string{"cmd"}, tt.args...)

r, w, _ := os.Pipe()
origStdout := os.Stdout
os.Stdout = w
defer func() { os.Stdout = origStdout }()

main()

w.Close()
var buf bytes.Buffer
_, err := io.Copy(&buf, r)
if err != nil {
return
}
result := buf.String()

assert.Contains(t, result, tt.output)
})
}
}
2 changes: 1 addition & 1 deletion internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
)

const VERSION = "0.2.0"
const VERSION = "0.3.0"

func Help() {
fmt.Println("Usage:")
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestVersion(t *testing.T) {
}{
{
name: "Version",
output: "cmt 0.2.0\n",
output: "cmt 0.3.0\n",
},
}

Expand Down

0 comments on commit 4b8d797

Please sign in to comment.