Skip to content

Commit

Permalink
cosmetic & comment updates on api package
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgooz committed Aug 23, 2018
1 parent fbc0639 commit 30de7fb
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 42 deletions.
6 changes: 4 additions & 2 deletions api/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ func DeployServiceStatusOption(statuses chan DeployStatus) DeployServiceOption {
}

// DeployService deploys a service from a gzipped tarball.
func (a *API) DeployService(r io.Reader, options ...DeployServiceOption) (*service.Service, *importer.ValidationError, error) {
func (a *API) DeployService(r io.Reader, options ...DeployServiceOption) (*service.Service,
*importer.ValidationError, error) {
return newServiceDeployer(a, options...).FromGzippedTar(r)
}

// DeployServiceFromURL deploys a service living at a Git host.
// Supported URL types:
// - https://github.com/mesg-foundation/service-ethereum
// - https://github.com/mesg-foundation/service-ethereum#branchName
func (a *API) DeployServiceFromURL(url string, options ...DeployServiceOption) (*service.Service, *importer.ValidationError, error) {
func (a *API) DeployServiceFromURL(url string, options ...DeployServiceOption) (*service.Service,
*importer.ValidationError, error) {
return newServiceDeployer(a, options...).FromGitURL(url)
}
89 changes: 50 additions & 39 deletions api/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,30 @@ func TestDeployService(t *testing.T) {
require.Equal(t, 1, structhash.Version(service.Id))
}()

status := <-statuses
require.Equal(t, RUNNING, status.Type)
require.Equal(t, "Sending service context to core daemon...", status.Message)

status = <-statuses
require.Equal(t, DONE, status.Type)
require.Equal(t, fmt.Sprintf("%s Service context sent to core daemon with success.", aurora.Green("✔")), status.Message)

status = <-statuses
require.Equal(t, RUNNING, status.Type)
require.Equal(t, "Building Docker image...", status.Message)

status = <-statuses
require.Equal(t, DONE, status.Type)
require.Equal(t, fmt.Sprintf("%s Image built with success.", aurora.Green("✔")), status.Message)

status = <-statuses
require.Equal(t, DONE, status.Type)
require.Equal(t, fmt.Sprintf("%s Completed.", aurora.Green("✔")), status.Message)
require.Equal(t, DeployStatus{
Message: "Sending service context to core daemon...",
Type: RUNNING,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: fmt.Sprintf("%s Service context sent to core daemon with success.", aurora.Green("✔")),
Type: DONE,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Building Docker image...",
Type: RUNNING,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: fmt.Sprintf("%s Image built with success.", aurora.Green("✔")),
Type: DONE,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: fmt.Sprintf("%s Completed.", aurora.Green("✔")),
Type: DONE,
}, <-statuses)

wg.Wait()
}
Expand Down Expand Up @@ -86,7 +91,8 @@ func TestDeployInvalidService(t *testing.T) {
}()

require.Equal(t, "Sending service context to core daemon...", (<-statuses).Message)
require.Equal(t, fmt.Sprintf("%s Service context sent to core daemon with success.", aurora.Green("✔")), (<-statuses).Message)
require.Equal(t, fmt.Sprintf("%s Service context sent to core daemon with success.", aurora.Green("✔")),
(<-statuses).Message)

select {
case <-statuses:
Expand Down Expand Up @@ -115,25 +121,30 @@ func TestDeployServiceFromURL(t *testing.T) {
require.Equal(t, 1, structhash.Version(service.Id))
}()

status := <-statuses
require.Equal(t, RUNNING, status.Type)
require.Equal(t, "Downloading service...", status.Message)

status = <-statuses
require.Equal(t, DONE, status.Type)
require.Equal(t, fmt.Sprintf("%s Service downloaded with success.", aurora.Green("✔")), status.Message)

status = <-statuses
require.Equal(t, RUNNING, status.Type)
require.Equal(t, "Building Docker image...", status.Message)

status = <-statuses
require.Equal(t, DONE, status.Type)
require.Equal(t, fmt.Sprintf("%s Image built with success.", aurora.Green("✔")), status.Message)

status = <-statuses
require.Equal(t, DONE, status.Type)
require.Equal(t, fmt.Sprintf("%s Completed.", aurora.Green("✔")), status.Message)
require.Equal(t, DeployStatus{
Message: "Downloading service...",
Type: RUNNING,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: fmt.Sprintf("%s Service downloaded with success.", aurora.Green("✔")),
Type: DONE,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Building Docker image...",
Type: RUNNING,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: fmt.Sprintf("%s Image built with success.", aurora.Green("✔")),
Type: DONE,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: fmt.Sprintf("%s Completed.", aurora.Green("✔")),
Type: DONE,
}, <-statuses)

wg.Wait()
}
2 changes: 1 addition & 1 deletion api/stop_stopper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/mesg-foundation/core/database/services"
)

// serviceStopper provides functionalities to start a MESG service.
// serviceStopper provides functionalities to stop a MESG service.
type serviceStopper struct {
api *API
}
Expand Down

0 comments on commit 30de7fb

Please sign in to comment.