Added (trivial) unit tests
Signed-off-by: Russ Magee <rmagee@gmail.com>
This commit is contained in:
parent
33f6583714
commit
147c4514a0
|
@ -1138,7 +1138,7 @@ func patchCompletedJobsInLog(orig []string, horizon int) (fixed []string) {
|
|||
currentStage, e := ioutil.ReadFile(runningJobs[jobID].workDir + "/_stage")
|
||||
if e == nil {
|
||||
//fixed[idx] = strings.Replace(fixed[idx], "<!--:STAGE:-->", " <img style='height:1em; margin:0px; padding:0px;' src='images/run-throbber.gif'/>[" + strings.TrimSpace(string(currentStage)) + "]", 1)
|
||||
fixed[idx] = strings.Replace(fixed[idx], "<!--:STAGE:-->", " [" + strings.TrimSpace(string(currentStage)) + "]", 1)
|
||||
fixed[idx] = strings.Replace(fixed[idx], "<!--:STAGE:-->", " ["+strings.TrimSpace(string(currentStage))+"]", 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package main
|
||||
|
||||
// Trivial unit tests. TODO: make these meaningful.
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test1favIconHTML(t *testing.T) {
|
||||
if favIconHTML() != `<link rel="icon" type="image/jpg" href="/images/logo.jpg"/>` {
|
||||
t.Error("Unexpected HTML fragment")
|
||||
}
|
||||
}
|
||||
|
||||
func Test2goBackJS(t *testing.T) {
|
||||
if goBackJS("2", "500") != `
|
||||
<script>
|
||||
// Go back after a short delay
|
||||
setInterval(function(){ /*window.location.href = document.referrer;*/ window.history.go(-2); }, 500);
|
||||
</script>
|
||||
` {
|
||||
t.Error("Unexpected JS fragment")
|
||||
}
|
||||
}
|
||||
|
||||
func Test3refreshMetaTag(t *testing.T) {
|
||||
if refreshMetaTag('r', "5") !=
|
||||
`<meta http-equiv="refresh" content="5">` {
|
||||
t.Error("Unexpected HTML fragment")
|
||||
}
|
||||
}
|
||||
|
||||
func Test4refreshMetaTagInvalidRune(t *testing.T) {
|
||||
if refreshMetaTag('x', "5") != `` {
|
||||
t.Error("Unexpected HTML fragment")
|
||||
}
|
||||
}
|
|
@ -21,6 +21,11 @@ commands:
|
|||
exec: |
|
||||
echo "TODO: cp binary and docs to ${releaseDir}"
|
||||
|
||||
tests:
|
||||
help: unit tests.
|
||||
exec:
|
||||
go test -v .
|
||||
|
||||
install:
|
||||
help: install binaries
|
||||
deps:
|
||||
|
@ -41,6 +46,8 @@ commands:
|
|||
app:
|
||||
aliases: [ build ]
|
||||
help: build the bacillus tool
|
||||
deps:
|
||||
- tests
|
||||
exec: |
|
||||
go clean .
|
||||
gofmt -w .
|
||||
|
|
|
@ -40,9 +40,11 @@ cd build
|
|||
git clone https://gogs.blitter.com/Russtopia/bacillus
|
||||
cd bacillus
|
||||
|
||||
stage "Build"
|
||||
stage "Tests"
|
||||
grml tests
|
||||
|
||||
go build .
|
||||
stage "Build"
|
||||
grml app
|
||||
|
||||
stage "Artifacts"
|
||||
|
||||
|
|
Loading…
Reference in New Issue