Skip to content

Commit

Permalink
move version test to integration (#789)
Browse files Browse the repository at this point in the history
Signed-off-by: Ramiro Berrelleza <rberrelleza@gmail.com>
  • Loading branch information
rberrelleza committed Mar 27, 2020
1 parent 5ff49ec commit e03bf7b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
7 changes: 4 additions & 3 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func upgradeAvailable() string {
return ""
}

v, err := getVersion()
v, err := GetLatestVersionFromGithub()
if err != nil {
log.Infof("failed to get latest version: %s", err)
log.Errorf("failed to get latest version from github: %s", err)
return ""
}

Expand All @@ -67,7 +67,8 @@ func upgradeAvailable() string {
return ""
}

func getVersion() (string, error) {
// GetLatestVersionFromGithub returns the latest okteto version from Github
func GetLatestVersionFromGithub() (string, error) {
client := github.NewClient(nil)
ctx := context.Background()
releases, _, err := client.Repositories.ListReleases(ctx, "okteto", "okteto", &github.ListOptions{PerPage: 5})
Expand Down
12 changes: 0 additions & 12 deletions cmd/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,3 @@ func Test_shouldNotify(t *testing.T) {
})
}
}

func TestGetVersion(t *testing.T) {
v, err := getVersion()
if err != nil {
t.Fatal(err)
}

_, err = semver.NewVersion(v)
if err != nil {
t.Fatal(err)
}
}
14 changes: 14 additions & 0 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import (
"text/template"
"time"

"github.com/Masterminds/semver"
ps "github.com/mitchellh/go-ps"
okCmd "github.com/okteto/okteto/cmd"
k8Client "github.com/okteto/okteto/pkg/k8s/client"
"github.com/okteto/okteto/pkg/syncthing"
"go.undefinedlabs.com/scopeagent"
Expand Down Expand Up @@ -143,6 +145,18 @@ func TestMain(m *testing.M) {
})))
}

func TestGetVersion(t *testing.T) {
v, err := okCmd.GetLatestVersionFromGithub()
if err != nil {
t.Fatal(err)
}

_, err = semver.NewVersion(v)
if err != nil {
t.Fatal(err)
}
}

func TestDownloadSyncthing(t *testing.T) {
var tests = []struct {
os string
Expand Down

0 comments on commit e03bf7b

Please sign in to comment.