mirror of https://github.com/docker/docs.git
Merge pull request #1895 from dmp42/8-test
Tests fixes / silence build / add unit tests
This commit is contained in:
commit
d063fe598d
|
@ -67,3 +67,35 @@ func TestGetUsername(t *testing.T) {
|
|||
t.Fatalf("expected username %s; received %s", currentUser, username)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateRandomID(t *testing.T) {
|
||||
id := GenerateRandomID()
|
||||
|
||||
if len(id) != 64 {
|
||||
t.Fatalf("Id returned is incorrect: %s", id)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShortenId(t *testing.T) {
|
||||
id := GenerateRandomID()
|
||||
truncID := TruncateID(id)
|
||||
if len(truncID) != 12 {
|
||||
t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShortenIdEmpty(t *testing.T) {
|
||||
id := ""
|
||||
truncID := TruncateID(id)
|
||||
if len(truncID) > len(id) {
|
||||
t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShortenIdInvalid(t *testing.T) {
|
||||
id := "1234"
|
||||
truncID := TruncateID(id)
|
||||
if len(truncID) != len(id) {
|
||||
t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ build-simple: $(PREFIX)/bin/$(PKG_NAME)
|
|||
|
||||
# XXX building with -a fails in debug (with -N -l) ????
|
||||
$(PREFIX)/bin/$(PKG_NAME): $(shell find . -type f -name '*.go')
|
||||
go build -o $@ $(VERBOSE_GO) -tags "$(BUILDTAGS)" -ldflags "$(GO_LDFLAGS)" $(GO_GCFLAGS) ./main.go
|
||||
@go build -o $@ $(VERBOSE_GO) -tags "$(BUILDTAGS)" -ldflags "$(GO_LDFLAGS)" $(GO_GCFLAGS) ./main.go
|
||||
|
||||
# Cross-build: careful, does always rebuild!
|
||||
build-x: clean
|
||||
|
|
|
@ -23,7 +23,7 @@ load ${BASE_TEST_DIR}/helpers.bash
|
|||
}
|
||||
|
||||
@test "$DRIVER: has status 'started' appearing in ls" {
|
||||
run machine ls --filter state=Running
|
||||
run machine ls -q --filter state=Running
|
||||
echo ${output}
|
||||
[ "$status" -eq 0 ]
|
||||
[[ ${lines[0]} == "$NAME" ]]
|
||||
|
@ -32,7 +32,7 @@ load ${BASE_TEST_DIR}/helpers.bash
|
|||
@test "$DRIVER: create with same name again fails" {
|
||||
run machine create -d $DRIVER $NAME
|
||||
echo ${output}
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$status" -eq 1 ]
|
||||
[[ ${lines[0]} == "Error creating machine: Machine $NAME already exists" ]]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue