1- package service
1+ package systems
22
33import (
44 "errors"
5- "github.com/jfrog/jfrog-cli-core/v2/utils/config"
6- "go.uber.org/mock/gomock"
75 "net/http"
86 "testing"
97
10- "github.com/jfrog/jfrog-cli-application/application/http/mocks"
8+ mockservice "github.com/jfrog/jfrog-cli-application/application/service/mocks"
9+ "go.uber.org/mock/gomock"
10+
11+ mockhttp "github.com/jfrog/jfrog-cli-application/application/http/mocks"
1112 "github.com/stretchr/testify/assert"
1213)
1314
@@ -35,7 +36,7 @@ func TestSystemService_Ping(t *testing.T) {
3536 },
3637 mockBody : []byte ("" ),
3738 mockError : nil ,
38- expectedError : errors .New ("failed to create app version . Status code: 500" ),
39+ expectedError : errors .New ("failed pinging application service . Status code: 500" ),
3940 },
4041 {
4142 name : "Ping failed with error" ,
@@ -51,16 +52,15 @@ func TestSystemService_Ping(t *testing.T) {
5152 ctrl := gomock .NewController (t )
5253 defer ctrl .Finish ()
5354
54- mockHttpClient := mock_http .NewMockAppHttpClient (ctrl )
55+ mockHttpClient := mockhttp .NewMockAppHttpClient (ctrl )
5556 mockHttpClient .EXPECT ().Get ("/v1/system/ping" ).
5657 Return (tt .mockResponse , tt .mockBody , tt .mockError )
5758
58- ctx := & Context {
59- ServerDetails : & config.ServerDetails {},
60- }
59+ mockCtx := mockservice .NewMockContext (ctrl )
60+ mockCtx .EXPECT ().GetHttpClient ().Return (mockHttpClient ).Times (1 )
6161
6262 ss := NewSystemService ()
63- err := ss .Ping (ctx )
63+ err := ss .Ping (mockCtx )
6464
6565 if tt .expectedError != nil {
6666 assert .EqualError (t , err , tt .expectedError .Error ())
0 commit comments