Skip to content

Commit b6cb3e2

Browse files
author
Olivier Gambier
committed
Tests fixes / silence build / add unit tests
Signed-off-by: Olivier Gambier <olivier@docker.com>
1 parent 1ae222b commit b6cb3e2

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

libmachine/mcnutils/utils_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,35 @@ func TestGetUsername(t *testing.T) {
6767
t.Fatalf("expected username %s; received %s", currentUser, username)
6868
}
6969
}
70+
71+
func TestGenerateRandomID(t *testing.T) {
72+
id := GenerateRandomID()
73+
74+
if len(id) != 64 {
75+
t.Fatalf("Id returned is incorrect: %s", id)
76+
}
77+
}
78+
79+
func TestShortenId(t *testing.T) {
80+
id := GenerateRandomID()
81+
truncID := TruncateID(id)
82+
if len(truncID) != 12 {
83+
t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
84+
}
85+
}
86+
87+
func TestShortenIdEmpty(t *testing.T) {
88+
id := ""
89+
truncID := TruncateID(id)
90+
if len(truncID) > len(id) {
91+
t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
92+
}
93+
}
94+
95+
func TestShortenIdInvalid(t *testing.T) {
96+
id := "1234"
97+
truncID := TruncateID(id)
98+
if len(truncID) != len(id) {
99+
t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
100+
}
101+
}

mk/build.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-simple: $(PREFIX)/bin/$(PKG_NAME)
66

77
# XXX building with -a fails in debug (with -N -l) ????
88
$(PREFIX)/bin/$(PKG_NAME): $(shell find . -type f -name '*.go')
9-
go build -o $@ $(VERBOSE_GO) -tags "$(BUILDTAGS)" -ldflags "$(GO_LDFLAGS)" $(GO_GCFLAGS) ./main.go
9+
@go build -o $@ $(VERBOSE_GO) -tags "$(BUILDTAGS)" -ldflags "$(GO_LDFLAGS)" $(GO_GCFLAGS) ./main.go
1010

1111
# Cross-build: careful, does always rebuild!
1212
build-x: clean

test/integration/core/core-commands.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ load ${BASE_TEST_DIR}/helpers.bash
2323
}
2424

2525
@test "$DRIVER: has status 'started' appearing in ls" {
26-
run machine ls --filter state=Running
26+
run machine ls -q --filter state=Running
2727
echo ${output}
2828
[ "$status" -eq 0 ]
2929
[[ ${lines[0]} == "$NAME" ]]
@@ -32,7 +32,7 @@ load ${BASE_TEST_DIR}/helpers.bash
3232
@test "$DRIVER: create with same name again fails" {
3333
run machine create -d $DRIVER $NAME
3434
echo ${output}
35-
[ "$status" -eq 0 ]
35+
[ "$status" -eq 1 ]
3636
[[ ${lines[0]} == "Error creating machine: Machine $NAME already exists" ]]
3737
}
3838

0 commit comments

Comments
 (0)