Skip to content

Commit

Permalink
Merge pull request #10 from ckaznocha/refactor
Browse files Browse the repository at this point in the history
chore(revert last change)
  • Loading branch information
Jeff DeCola committed Sep 25, 2016
2 parents cc46198 + d9e32ea commit 8a5a4ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
18 changes: 6 additions & 12 deletions cmd/marathon-resource/marathon/marathon.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ type (
//Marathoner is an interface to interact with marathon
Marathoner interface {
LatestVersions(appID string, version string) ([]string, error)
GetApp(appID, version string) (Application, error)
UpdateApp(Application) (DeploymentID, error)
GetApp(appID, version string) (gomarathon.Application, error)
UpdateApp(gomarathon.Application) (gomarathon.DeploymentID, error)
CheckDeployment(deploymentID string) (bool, error)
DeleteDeployment(deploymentID string) error
}
Expand All @@ -45,12 +45,6 @@ type (
UserName string `json:"user_name"`
Password string `json:"password"`
}

//Application is a marathon application
Application gomarathon.Application

//DeploymentID is a marathon deploymentID
DeploymentID gomarathon.DeploymentID
)

//NewMarathoner returns a new marathoner
Expand Down Expand Up @@ -117,8 +111,8 @@ func (m *marathon) LatestVersions(appID, version string) ([]string, error) {
return dates.NewerTimestamps(v.Versions, version)
}

func (m *marathon) GetApp(appID, version string) (Application, error) {
var app Application
func (m *marathon) GetApp(appID, version string) (gomarathon.Application, error) {
var app gomarathon.Application
err := m.handleReq(
http.MethodGet,
fmt.Sprintf(pathAppAtVersion, appID, version),
Expand All @@ -129,10 +123,10 @@ func (m *marathon) GetApp(appID, version string) (Application, error) {
return app, err
}

func (m *marathon) UpdateApp(inApp Application) (DeploymentID, error) {
func (m *marathon) UpdateApp(inApp gomarathon.Application) (gomarathon.DeploymentID, error) {
var (
payload, _ = json.Marshal(inApp)
deployment DeploymentID
deployment gomarathon.DeploymentID
)
err := m.handleReq(
http.MethodPut,
Expand Down
14 changes: 7 additions & 7 deletions cmd/marathon-resource/marathon/marathon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func Test_marathon_GetApp(t *testing.T) {
u, _ = url.Parse("http://foo.bar/")
)
defer ctrl.Finish()
in, _ := json.Marshal(Application{ID: "hello-app"})
in, _ := json.Marshal(gomarathon.Application{ID: "hello-app"})
mockClient.EXPECT().Do(gomock.Any()).Times(1).Return(
&http.Response{
StatusCode: http.StatusOK,
Expand All @@ -234,10 +234,10 @@ func Test_marathon_GetApp(t *testing.T) {
name string
fields fields
args args
want Application
want gomarathon.Application
wantErr bool
}{
{"Works", fields{mockClient, u}, args{"hello-app", "2015-02-11T09:31:50.021Z"}, Application{ID: "hello-app"}, false},
{"Works", fields{mockClient, u}, args{"hello-app", "2015-02-11T09:31:50.021Z"}, gomarathon.Application{ID: "hello-app"}, false},
}
for _, tt := range tests {
m := &marathon{
Expand All @@ -262,7 +262,7 @@ func Test_marathon_UpdateApp(t *testing.T) {
u, _ = url.Parse("http://foo.bar/")
)
defer ctrl.Finish()
out, _ := json.Marshal(DeploymentID{DeploymentID: "foo"})
out, _ := json.Marshal(gomarathon.DeploymentID{DeploymentID: "foo"})
mockClient.EXPECT().Do(gomock.Any()).Times(1).Return(
&http.Response{
StatusCode: http.StatusOK,
Expand All @@ -275,16 +275,16 @@ func Test_marathon_UpdateApp(t *testing.T) {
url *url.URL
}
type args struct {
inApp Application
inApp gomarathon.Application
}
tests := []struct {
name string
fields fields
args args
want DeploymentID
want gomarathon.DeploymentID
wantErr bool
}{
{"Works", fields{mockClient, u}, args{Application{ID: "foo-app"}}, DeploymentID{DeploymentID: "foo"}, false},
{"Works", fields{mockClient, u}, args{gomarathon.Application{ID: "foo-app"}}, gomarathon.DeploymentID{DeploymentID: "foo"}, false},
}
for _, tt := range tests {
m := &marathon{
Expand Down

0 comments on commit 8a5a4ac

Please sign in to comment.