fix no profiles
This commit is contained in:
parent
a217d13046
commit
8aa7057b86
@ -59,7 +59,7 @@ goc profile --force
|
||||
}
|
||||
res, err := cover.NewWorker(center).Profile(p)
|
||||
if err != nil {
|
||||
log.Fatalf("call host %v failed, err: %v, response: %v", center, err, string(res))
|
||||
log.Fatalf("Goc server %v return an error: %v", center, err)
|
||||
}
|
||||
|
||||
if output == "" {
|
||||
|
@ -75,46 +75,51 @@ func TestClientAction(t *testing.T) {
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
name: "valid test with no service flag provied",
|
||||
name: "valid test with no service flag provide",
|
||||
service: Service{Name: "serviceOK", Address: profileSuccessMockSvr.URL},
|
||||
param: ProfileParam{},
|
||||
expected: "mockService/main.go:30.13,48.33 13 1",
|
||||
},
|
||||
{
|
||||
name: "valid test with service flag provied",
|
||||
name: "valid test with service flag provide",
|
||||
service: Service{Name: "serviceOK", Address: profileSuccessMockSvr.URL},
|
||||
param: ProfileParam{Service: []string{"serviceOK"}},
|
||||
expected: "mockService/main.go:30.13,48.33 13 1",
|
||||
},
|
||||
{
|
||||
name: "valid test with address flag provied",
|
||||
name: "valid test with address flag provide",
|
||||
service: Service{Name: "serviceOK", Address: profileSuccessMockSvr.URL},
|
||||
param: ProfileParam{Address: []string{profileSuccessMockSvr.URL}},
|
||||
expected: "mockService/main.go:30.13,48.33 13 1",
|
||||
},
|
||||
{
|
||||
name: "invalid test with invalid service flag provide",
|
||||
service: Service{Name: "serviceOK", Address: profileSuccessMockSvr.URL},
|
||||
param: ProfileParam{Service: []string{"unknown"}},
|
||||
expected: "service [unknown] not found",
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid test with invalid profile got by service",
|
||||
service: Service{Name: "serviceErr", Address: profileErrMockSvr.URL},
|
||||
expected: "bad mode line: error",
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid test with disconnected service",
|
||||
service: Service{Name: "serviceNotExist", Address: "http://172.0.0.2:7777"},
|
||||
expected: "connection refused",
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
service: Service{Name: "serviceNotExist", Address: "http://172.0.0.2:7777"},
|
||||
param: ProfileParam{Force: true},
|
||||
expected: `{"message":"no profiles"}`,
|
||||
name: "invalid test with empty profile",
|
||||
service: Service{Name: "serviceNotExist", Address: "http://172.0.0.2:7777"},
|
||||
param: ProfileParam{Force: true},
|
||||
expectedErr: true,
|
||||
expected: "no profiles",
|
||||
},
|
||||
{
|
||||
name: "valid test with coverfile flag provied",
|
||||
name: "valid test with coverfile flag provide",
|
||||
service: Service{Name: "serviceOK", Address: profileSuccessMockSvr.URL},
|
||||
param: ProfileParam{CoverFilePatterns: []string{"b.go$"}},
|
||||
expected: "b/b.go",
|
||||
|
@ -173,7 +173,7 @@ func profile(c *gin.Context) {
|
||||
}
|
||||
|
||||
if len(mergedProfiles) == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"message": "no profiles"})
|
||||
c.JSON(http.StatusExpectationFailed, gin.H{"error": "no profiles"})
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -94,6 +94,40 @@ setup() {
|
||||
[[ "$output" == *"b.go"* ]] # contains b.go file
|
||||
[[ "$output" != *"main.go"* ]] # not contains main.go file
|
||||
|
||||
wait $profile_pid
|
||||
kill -9 $SAMPLE_PID
|
||||
}
|
||||
|
||||
@test "test goc profile with service flag" {
|
||||
./simple-project 3>&- &
|
||||
SAMPLE_PID=$!
|
||||
sleep 2
|
||||
|
||||
wait_profile_backend "profile4" &
|
||||
profile_pid=$!
|
||||
|
||||
run gocc profile --center=http://127.0.0.1:60001 --service="simple-project" --debug --debugcisyncfile ci-sync.bak;
|
||||
info $output
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"mode: count"* ]]
|
||||
|
||||
wait $profile_pid
|
||||
kill -9 $SAMPLE_PID
|
||||
}
|
||||
|
||||
@test "test goc profile with force flag" {
|
||||
./simple-project 3>&- &
|
||||
SAMPLE_PID=$!
|
||||
sleep 2
|
||||
|
||||
wait_profile_backend "profile5" &
|
||||
profile_pid=$!
|
||||
|
||||
run gocc profile --center=http://127.0.0.1:60001 --service="simple-project,unknown" --force --debug --debugcisyncfile ci-sync.bak;
|
||||
info $output
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"mode: count"* ]]
|
||||
|
||||
wait $profile_pid
|
||||
kill -9 $SAMPLE_PID
|
||||
}
|
@ -41,7 +41,8 @@ teardown_file() {
|
||||
[ "$status" -eq 0 ]
|
||||
# connect to covered goc
|
||||
run goc profile --center=http://127.0.0.1:60001
|
||||
[ "$status" -eq 0 ]
|
||||
# no profiles
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "register a covered service" {
|
||||
@ -54,5 +55,5 @@ teardown_file() {
|
||||
sleep 1
|
||||
# connect to covered goc
|
||||
run goc profile --center=http://127.0.0.1:60001
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
Loading…
Reference in New Issue
Block a user