-
Notifications
You must be signed in to change notification settings - Fork 10
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
1 parent
1aea4c0
commit 82b8e82
Showing
11 changed files
with
546 additions
and
57 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
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 |
---|---|---|
@@ -0,0 +1,173 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
var demoInputOk input = input{ | ||
asyncFlag:asyncFlag(false), | ||
configPath:configPath("/demo"), | ||
keyPath:keyPath("/demo"), | ||
serverGroup:serverGroup("demoServerGroup"), | ||
commandName:commandName("demo"), | ||
verifyFlag:verifyFlag(false), | ||
} | ||
|
||
var demoInputNotOk input = input{ | ||
asyncFlag:asyncFlag(false), | ||
configPath:configPath(""), | ||
keyPath:keyPath(""), | ||
serverGroup:serverGroup(""), | ||
verifyFlag:verifyFlag(true), | ||
} | ||
|
||
func TestParse(t *testing.T) { | ||
in := input{} | ||
in.parse() | ||
} | ||
|
||
func TestValidateInput(t *testing.T) { | ||
//should not panic | ||
func() { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
t.FailNow() | ||
} | ||
}() | ||
demoInputOk.validate() | ||
}() | ||
//should panic | ||
func() { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
recover() | ||
} | ||
}() | ||
demoInputNotOk.validate() | ||
t.FailNow() | ||
}() | ||
|
||
} | ||
|
||
func TestValidateConfigPath(t *testing.T) { | ||
//should not panic | ||
func() { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
t.FailNow() | ||
} | ||
}() | ||
demoInputOk.configPath.validate() | ||
}() | ||
//should panic | ||
func() { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
recover() | ||
} | ||
}() | ||
demoInputNotOk.configPath.validate() | ||
t.FailNow() | ||
}() | ||
} | ||
|
||
func TestValidateKeyPath(t *testing.T) { | ||
//should not panic | ||
func() { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
t.FailNow() | ||
} | ||
}() | ||
demoInputOk.keyPath.validate() | ||
}() | ||
//should panic | ||
func() { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
recover() | ||
} | ||
}() | ||
demoInputNotOk.keyPath.validate() | ||
t.FailNow() | ||
}() | ||
} | ||
|
||
func TestValidateServerGroup(t *testing.T) { | ||
//should not panic | ||
func() { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
t.FailNow() | ||
} | ||
}() | ||
demoInputOk.serverGroup.validate() | ||
}() | ||
//should panic | ||
func() { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
recover() | ||
} | ||
}() | ||
demoInputNotOk.serverGroup.validate() | ||
t.FailNow() | ||
}() | ||
} | ||
|
||
func TestValidateCommandName(t *testing.T) { | ||
//should not panic | ||
func() { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
t.FailNow() | ||
} | ||
}() | ||
demoInputOk.commandName.validate() | ||
}() | ||
//should panic | ||
func() { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
recover() | ||
} | ||
}() | ||
demoInputNotOk.commandName.validate() | ||
t.FailNow() | ||
}() | ||
} | ||
|
||
func TestVerifyAction(t *testing.T) { | ||
|
||
s := servers{ | ||
server{ | ||
Name:"testN", | ||
Host:"testH", | ||
User:"testU", | ||
}, | ||
} | ||
|
||
//should panic | ||
func() { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
recover() | ||
} | ||
}() | ||
demoInputOk.verifyAction(s) | ||
t.FailNow() | ||
}() | ||
|
||
//should not panic | ||
func() { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
t.FailNow() | ||
} | ||
}() | ||
demoInputOk.verifyFlag = true | ||
demoInputOk.verifyAction(s) | ||
}() | ||
|
||
|
||
} |
Oops, something went wrong.