-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,100 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMain(t *testing.T) { | ||
assert.Equal(t, 1, 1) | ||
tests := []struct { | ||
desc string | ||
args []string | ||
wantError bool | ||
}{ | ||
{ | ||
desc: "正常系: align left", | ||
args: []string{"align", "left", "README.adoc"}, | ||
wantError: false, | ||
}, | ||
{ | ||
desc: "正常系: align l", | ||
args: []string{"align", "l", "README.adoc"}, | ||
wantError: false, | ||
}, | ||
{ | ||
desc: "正常系: align center", | ||
args: []string{"align", "center", "README.adoc"}, | ||
wantError: false, | ||
}, | ||
{ | ||
desc: "正常系: align c", | ||
args: []string{"align", "c", "README.adoc"}, | ||
wantError: false, | ||
}, | ||
{ | ||
desc: "正常系: align right", | ||
args: []string{"align", "right", "README.adoc"}, | ||
wantError: false, | ||
}, | ||
{ | ||
desc: "正常系: align r", | ||
args: []string{"align", "r", "README.adoc"}, | ||
wantError: false, | ||
}, | ||
{ | ||
desc: "正常系: align vertical-top", | ||
args: []string{"align", "vertical-top", "README.adoc"}, | ||
wantError: false, | ||
}, | ||
{ | ||
desc: "正常系: align vt", | ||
args: []string{"align", "vt", "README.adoc"}, | ||
wantError: false, | ||
}, | ||
{ | ||
desc: "正常系: align vertical-center", | ||
args: []string{"align", "vertical-center", "README.adoc"}, | ||
wantError: false, | ||
}, | ||
{ | ||
desc: "正常系: align vc", | ||
args: []string{"align", "vc", "README.adoc"}, | ||
wantError: false, | ||
}, | ||
{ | ||
desc: "正常系: align vertical-bottom", | ||
args: []string{"align", "vertical-bottom", "README.adoc"}, | ||
wantError: false, | ||
}, | ||
{ | ||
desc: "正常系: align vb", | ||
args: []string{"align", "vb", "README.adoc"}, | ||
wantError: false, | ||
}, | ||
{ | ||
desc: "正常系: align --help", | ||
args: []string{"align", "--help"}, | ||
wantError: false, | ||
}, | ||
{ | ||
desc: "異常系: 存在しないサブコマンド", | ||
args: []string{"align", "foobar"}, | ||
wantError: true, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.desc, func(t *testing.T) { | ||
assert := assert.New(t) | ||
os.Args = tt.args | ||
err := Main() | ||
if tt.wantError { | ||
assert.Error(err) | ||
return | ||
} | ||
assert.NoError(err) | ||
}) | ||
} | ||
} |