Skip to content

Commit 3c56f25

Browse files
committed
Added stub tests of the subcommand setup
1 parent 99ec19c commit 3c56f25

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed

cmd_add_user_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package main
2+
3+
import (
4+
"strings"
5+
"testing"
6+
)
7+
8+
func TestAddUserName(t *testing.T) {
9+
s := addUserCmd{}
10+
if s.Name() != "add-user" {
11+
t.Errorf("Field didn't match")
12+
}
13+
}
14+
15+
func TestAddUserSynopsis(t *testing.T) {
16+
s := addUserCmd{}
17+
if s.Synopsis() != "Add a new user." {
18+
t.Errorf("Field didn't match")
19+
}
20+
}
21+
22+
func TestAddUserUsage(t *testing.T) {
23+
s := addUserCmd{}
24+
if !strings.Contains(s.Usage(), "Add a new") {
25+
t.Errorf("Field didn't match")
26+
}
27+
}

cmd_del_user_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package main
2+
3+
import (
4+
"strings"
5+
"testing"
6+
)
7+
8+
func TestDElUserName(t *testing.T) {
9+
s := delUserCmd{}
10+
if s.Name() != "del-user" {
11+
t.Errorf("Field didn't match")
12+
}
13+
}
14+
15+
func TestDelUserSynopsis(t *testing.T) {
16+
s := delUserCmd{}
17+
if s.Synopsis() != "Delete an existing user." {
18+
t.Errorf("Field didn't match")
19+
}
20+
}
21+
22+
func TestDelUserUsage(t *testing.T) {
23+
s := delUserCmd{}
24+
if !strings.Contains(s.Usage(), "Remove a user") {
25+
t.Errorf("Field didn't match")
26+
}
27+
}

cmd_list_users_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package main
2+
3+
import (
4+
"strings"
5+
"testing"
6+
)
7+
8+
func TestListUsersName(t *testing.T) {
9+
s := listUsersCmd{}
10+
if s.Name() != "list-users" {
11+
t.Errorf("Field didn't match")
12+
}
13+
}
14+
15+
func TestListUsersSynopsis(t *testing.T) {
16+
s := listUsersCmd{}
17+
if s.Synopsis() != "List our existing users." {
18+
t.Errorf("Field didn't match")
19+
}
20+
}
21+
22+
func TestListUsersUsage(t *testing.T) {
23+
s := listUsersCmd{}
24+
if !strings.Contains(s.Usage(), "Show all the existing") {
25+
t.Errorf("Field didn't match")
26+
}
27+
}

cmd_serve_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package main
2+
3+
import (
4+
"strings"
5+
"testing"
6+
)
7+
8+
func TestServeName(t *testing.T) {
9+
s := serveCmd{}
10+
if s.Name() != "serve" {
11+
t.Errorf("Field didn't match")
12+
}
13+
}
14+
15+
func TestServeSynopsis(t *testing.T) {
16+
s := serveCmd{}
17+
if s.Synopsis() != "Launch the HTTP server." {
18+
t.Errorf("Field didn't match")
19+
}
20+
}
21+
22+
func TestServeUsage(t *testing.T) {
23+
s := serveCmd{}
24+
if !strings.Contains(s.Usage(), "Launch the HTTP server for") {
25+
t.Errorf("Field didn't match")
26+
}
27+
}

0 commit comments

Comments
 (0)