mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-18 14:36:30 +00:00
b027bd8392
Run `go fmt ./...` [1] and add a test to the `test` make target that checks if `go fmt` has been run. [1]: http://blog.golang.org/go-fmt-your-code
69 lines
1.9 KiB
Go
69 lines
1.9 KiB
Go
package script
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestDockerNetworkMode(t *testing.T) {
|
|
var d *Docker
|
|
var expected string
|
|
|
|
expected = DefaultDockerNetworkMode
|
|
d = nil
|
|
if actual := DockerNetworkMode(d); actual != expected {
|
|
t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual)
|
|
}
|
|
|
|
expected = DefaultDockerNetworkMode
|
|
d = &Docker{}
|
|
if actual := DockerNetworkMode(d); actual != expected {
|
|
t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual)
|
|
}
|
|
|
|
expected = DefaultDockerNetworkMode
|
|
d = &Docker{NetworkMode: nil}
|
|
if actual := DockerNetworkMode(d); actual != expected {
|
|
t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual)
|
|
}
|
|
|
|
expected = "bridge"
|
|
d = &Docker{NetworkMode: &expected}
|
|
if actual := DockerNetworkMode(d); actual != expected {
|
|
t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual)
|
|
}
|
|
|
|
expected = "host"
|
|
d = &Docker{NetworkMode: &expected}
|
|
if actual := DockerNetworkMode(d); actual != expected {
|
|
t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual)
|
|
}
|
|
}
|
|
|
|
func TestDockerHostname(t *testing.T) {
|
|
var d *Docker
|
|
var expected string
|
|
|
|
expected = ""
|
|
d = nil
|
|
if actual := DockerHostname(d); actual != expected {
|
|
t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual)
|
|
}
|
|
|
|
expected = ""
|
|
d = &Docker{}
|
|
if actual := DockerHostname(d); actual != expected {
|
|
t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual)
|
|
}
|
|
|
|
expected = ""
|
|
d = &Docker{Hostname: nil}
|
|
if actual := DockerHostname(d); actual != expected {
|
|
t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual)
|
|
}
|
|
|
|
expected = "host"
|
|
d = &Docker{Hostname: &expected}
|
|
if actual := DockerHostname(d); actual != expected {
|
|
t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual)
|
|
}
|
|
}
|