Skip to content

Commit 46abbdb

Browse files
author
Uğur Özyılmazel
committed
Add app tests
1 parent ce34c86 commit 46abbdb

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

Rakefile

-19
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,9 @@ task :test, [:verbose] do |_, args|
4747
system "go test #{args.verbose} ./..."
4848
end
4949

50-
desc "Run doc server"
51-
task :serve_doc, [:port] do |_, args|
52-
args.with_defaults(port: 6060)
53-
url = "http://127.0.0.1:#{args.port}"
54-
55-
pages = [
56-
'scraper-cli',
57-
]
58-
59-
puts "Doc server is running at: #{url}...\n\n"
60-
pages.each do |u|
61-
puts "#{url}/pkg/github.com/promptapi/#{u}/"
62-
end
63-
puts "\n"
64-
65-
system "godoc -http=:#{args.port}"
66-
end
67-
6850
ORGANIZATION_NAME = "promptapi"
6951
REPO_NAME = "scraper-cli"
7052

71-
7253
desc "Publish project with revision: #{AVAILABLE_REVISIONS.join(',')}, default: patch"
7354
task :publish, [:revision] do |_, args|
7455
args.with_defaults(revision: "patch")

pkg/app/app_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package app
2+
3+
import (
4+
"bytes"
5+
"os"
6+
"testing"
7+
)
8+
9+
var cmd *CLIApplication
10+
11+
func TestMain(m *testing.M) {
12+
cmd = NewCLIApplication()
13+
os.Exit(m.Run())
14+
}
15+
16+
func TestAppVersion(t *testing.T) {
17+
t.Run("app should have a version information", func(t *testing.T) {
18+
19+
buff := new(bytes.Buffer)
20+
21+
*optVersionInformation = true
22+
cmd.Out = buff
23+
cmd.Run()
24+
25+
curVersion := string(bytes.TrimSpace(buff.Bytes()))
26+
if curVersion != version {
27+
t.Errorf("want: %s, got: %s", version, curVersion)
28+
}
29+
})
30+
}

0 commit comments

Comments
 (0)