Skip to content

Commit 66dc230

Browse files
Sazon, John Bryan Jbzon
authored andcommitted
Apply necessary fixes for failing travis ci build
1 parent a4d1c25 commit 66dc230

File tree

10 files changed

+44
-29
lines changed

10 files changed

+44
-29
lines changed

.travis.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ services:
1616
before_install:
1717
- docker-compose up -d
1818
- |
19-
jq --version
2019
21-
source testdata/credentials.sh
20+
jq --version
2221
2322
ctr=0
2423
max_retries=30
25-
while [ $(curl -I -u "${GITLAB_USERNAME}:${GITLAB_PASSWORD}" ${GITLAB_HTTP_URL}/users/sign_in | head -1 | grep 200 | wc -l | tr -d ' ') -ne 1 ]; do
24+
while [ $(curl -I -u "root:123qwe123" http://localhost:10080/users/sign_in | head -1 | grep 200 | wc -l | tr -d ' ') -ne 1 ]; do
2625
ctr=`expr $ctr + 1`
2726
echo waiting for gitlab to come up
2827
sleep 10
@@ -31,17 +30,34 @@ before_install:
3130
exit 1
3231
fi
3332
done
34-
echo "============ setting up test data ============="
33+
34+
###################################################
35+
# WARM UP TIME (don't mind me)
36+
###################################################
37+
sleep_time=100
38+
echo "sleeping for ${sleep_time} seconds"
39+
sleep ${sleep_time}
40+
source testdata/credentials.sh
3541
env | grep GITLAB
42+
###################################################
43+
44+
echo "============ setting up test data ============="
3645
GITLAB_USERNAME=$GITLAB_USERNAME GITLAB_PASSWORD=$GITLAB_PASSWORD GITLAB_HTTP_URL=$GITLAB_HTTP_URL ./testdata/seeder.sh
3746
echo "============ test data completed ============="
47+
- go get github.com/golang/lint/golint
48+
- make getdep
3849

3950
script:
40-
- go get github.com/golang/lint/golint
4151
- golint -set_exit_status ./...
4252
- |
4353
source testdata/credentials.sh
44-
make coverage
54+
go run main.go get users
55+
go run main.go get groups
56+
go run main.go get projects
57+
travis_wait 30 make coverage
58+
59+
after_script:
60+
- sleep 1
4561

4662
after_success:
4763
- bash <(curl -s https://codecov.io/bash) # Set CODECOV_TOKEN in your environment variables.

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ test: getdep
4141
go test -v ./... -failfast
4242

4343
coverage: getdep
44-
go test -v ./... -failfast -race -coverprofile=coverage.txt -covermode=atomic
44+
rm -f ~/.gitlabctl.yaml
45+
go test -cpu=1 -v ./... -failfast -coverprofile=coverage.txt -covermode=count
4546

4647
getdep:
4748
go get -v ./...

cmd/completion_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ package cmd
2222

2323
import (
2424
"testing"
25-
26-
"github.com/stretchr/testify/require"
2725
)
2826

2927
func TestCompletion(t *testing.T) {
@@ -65,8 +63,7 @@ func TestCompletion(t *testing.T) {
6563
noParent: true,
6664
}
6765
stdout, execResult := execT.executeCommand()
68-
require.Equal(t, tc.expect, execResult,
69-
printFlagsTable(tc.flagsMap, stdout))
66+
assertEqualResult(t, execResult, tc.expect, printFlagsTable(tc.flagsMap, stdout))
7067
})
7168
}
7269
}

cmd/delete_project_hook_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ func TestDeleteProjectHook(t *testing.T) {
3737
}{
3838
{
3939
name: "successfully delete a project hook",
40-
args: []string{""}, // to be filled in test setup
4140
flagsMap: map[string]string{
4241
"project": "23",
4342
},
@@ -65,7 +64,7 @@ func TestDeleteProjectHook(t *testing.T) {
6564
if err != nil {
6665
tInfo(fmt.Sprintf("failed to create project hook %s", tc.args[0]))
6766
}
68-
tc.args[0] = strconv.Itoa(hook.ID)
67+
tc.args = append(tc.args, strconv.Itoa(hook.ID))
6968
}
7069

7170
execT := execTestCmdFlags{

cmd/edit_project_hook_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ package cmd
2121

2222
import (
2323
"testing"
24-
25-
"github.com/stretchr/testify/require"
2624
)
2725

2826
func TestEditProjectHook(t *testing.T) {
@@ -83,8 +81,7 @@ func TestEditProjectHook(t *testing.T) {
8381
args: tc.args,
8482
}
8583
stdout, execResult := execT.executeCommand()
86-
require.Equal(t, tc.expect, execResult,
87-
printFlagsTable(tc.flagsMap, stdout))
84+
assertEqualResult(t, execResult, tc.expect, printFlagsTable(tc.flagsMap, stdout))
8885
})
8986
}
9087
}

cmd/gitlab_client_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"os"
55
"testing"
66

7-
"github.com/stretchr/testify/assert"
87
gitlab "github.com/xanzy/go-gitlab"
98
)
109

@@ -74,15 +73,17 @@ func TestGitlabNewClient(t *testing.T) {
7473
// Run the test
7574
t.Run(tc.name, func(t *testing.T) {
7675
gitlabClient, err := newGitlabClient()
77-
if tc.negativeTest {
78-
tInfo(err)
79-
assert.NotNil(t, err)
80-
} else {
81-
assert.Nil(t, err)
76+
if err != nil && !tc.negativeTest {
77+
t.Fatalf("gitlab client test is expected to pass: %+v", err)
78+
}
79+
if err == nil && tc.negativeTest {
80+
t.Fatalf("gitlab client test is expected to fail: %+v", err)
8281
}
8382
if !tc.negativeTest {
8483
_, _, err = gitlabClient.Users.ListUsers(&gitlab.ListUsersOptions{})
85-
assert.Nil(t, err)
84+
if err != nil {
85+
t.Fatalf("gitlab client test is expected to pass: %+v", err)
86+
}
8687
}
8788
})
8889
}

docs/gitlabctl_delete.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Delete a Gitlab resource
2121
### SEE ALSO
2222

2323
* [gitlabctl](gitlabctl.md) - Gitlab command-line interface
24-
* [gitlabctl delete all-members](gitlabctl_delete_all-members.md) - Delete all members(except creator) of a project
24+
* [gitlabctl delete all-members](gitlabctl_delete_all-members.md) - Delete all members of a project
2525
* [gitlabctl delete branch](gitlabctl_delete_branch.md) - Delete a project branch
2626
* [gitlabctl delete group](gitlabctl_delete_group.md) - Delete a Gitlab group by specifying the id or group path
2727
* [gitlabctl delete member](gitlabctl_delete_member.md) - Delete a member by specifying the member name as the first argument

docs/gitlabctl_delete_all-members.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## gitlabctl delete all-members
22

3-
Delete all members(except creator) of a project
3+
Delete all members of a project
44

55
### Synopsis
66

7-
Delete all members(except creator) of a project
7+
Delete all members of a project
88

99
```
1010
gitlabctl delete all-members [flags]
@@ -13,7 +13,6 @@ gitlabctl delete all-members [flags]
1313
### Examples
1414

1515
```
16-
# remove all members(except creator) from a project
1716
gitlabctl delete all-members --from-project Group1/Project1
1817
```
1918

testdata/credentials.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/bin/bash -e
2+
13
export GITLAB_USERNAME=root
24
export GITLAB_PASSWORD=123qwe123
35
export GITLAB_HTTP_URL=${GITLAB_HTTP_URL:-http://localhost:10080}

testdata/seeder.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash -ex
1+
#!/bin/bash -e
22

33
echo "=============================================="
44
echo "# SEEDER SCRIPT #"
@@ -42,6 +42,9 @@ sgroup2_id=$(curl -X POST "${GITLAB_HTTP_URL}/api/v4/groups?access_token=${acces
4242
sgroup3_id=$(curl -X POST "${GITLAB_HTTP_URL}/api/v4/groups?access_token=${access_token}&name=SubGroup3&path=SubGroup3&parent_id=${pgroup2_id}" | jq '.id')
4343
sgroup4_id=$(curl -X POST "${GITLAB_HTTP_URL}/api/v4/groups?access_token=${access_token}&name=SubGroup4&path=SubGroup4&parent_id=${pgroup2_id}" | jq '.id')
4444

45+
echo sleeping for 5 seconds..
46+
sleep 5
47+
4548
# create group project
4649
echo "Creating a project in group/subgroup"
4750
groupproject1_id=$(curl -X POST "${GITLAB_HTTP_URL}/api/v4/projects?access_token=${access_token}&name=Project1&namespace_id=${pgroup1_id}" | jq '.id')

0 commit comments

Comments
 (0)