Skip to content

Commit d84e67c

Browse files
author
Keerthan Mala
committed
fix the unit tests
1 parent b5aea06 commit d84e67c

12 files changed

+500
-477
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ DEV_ENV_IMAGE := quay.io/deis/go-dev:0.9.1
1212
SWAGGER_IMAGE := quay.io/goswagger/swagger:0.5.0
1313
DEV_ENV_WORK_DIR := /go/src/${REPO_PATH}
1414
DEV_ENV_PREFIX := docker run --rm -e GO15VENDOREXPERIMENT=1 -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR}
15-
DEV_ENV_CMD := ${DEV_ENV_PREFIX} ${DEV_ENV_IMAGE}
15+
DEV_ENV_CMD := ${DEV_ENV_PREFIX} -e GODEBUG=cgocheck=0 ${DEV_ENV_IMAGE}
1616
SWAGGER_CMD := docker run --rm -e GOPATH=/go -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${SWAGGER_IMAGE}
1717

1818
# SemVer with build information is defined in the SemVer 2 spec, but Docker

filter_by_age_test.go

-77
This file was deleted.

get_latest_versions_test.go

-85
This file was deleted.

pkg/data/cluster_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"time"
88

99
"github.com/arschles/assert"
10-
"github.com/deis/workflow-manager/types"
10+
"github.com/deis/workflow-manager-api/pkg/swagger/models"
1111
"github.com/jinzhu/gorm"
1212
)
1313

@@ -35,10 +35,10 @@ func newDB() (*gorm.DB, error) {
3535
return db, nil
3636
}
3737

38-
func testCluster() ClusterStateful {
39-
cluster := ClusterStateful{}
38+
func testCluster() models.Cluster {
39+
cluster := models.Cluster{}
4040
cluster.ID = clusterID
41-
cluster.Components = []types.ComponentVersion{testComponentVersion()}
41+
cluster.Components = []*models.ComponentVersion{testComponentVersion()}
4242
return cluster
4343
}
4444

@@ -47,15 +47,16 @@ func TestClusterRoundTrip(t *testing.T) {
4747
assert.NoErr(t, err)
4848
cluster, err := GetCluster(sqliteDB, clusterID)
4949
assert.True(t, err != nil, "error not returned when expected")
50-
assert.Equal(t, cluster, ClusterStateful{}, "returned cluster")
50+
assert.Equal(t, cluster, models.Cluster{}, "returned cluster")
5151
expectedCluster := testCluster()
5252
// the first time we invoke .CheckInAndSetCluster() it will create a new record
5353
newCluster, err := UpsertCluster(sqliteDB, clusterID, expectedCluster)
5454
assert.NoErr(t, err)
5555
assert.Equal(t, newCluster.ID, expectedCluster.ID, "cluster ID property")
5656
assert.Equal(t, newCluster.Components[0].Component.Description, expectedCluster.Components[0].Component.Description, "cluster component description property")
5757
// modify the cluster object
58-
expectedCluster.Components[0].Component.Description = "new description"
58+
desc := "new description"
59+
expectedCluster.Components[0].Component.Description = &desc
5960
// the next time we invoke .CheckInAndSetCluster() it should update the existing record we just created
6061
updatedCluster, err := UpsertCluster(sqliteDB, clusterID, expectedCluster)
6162
assert.NoErr(t, err)

pkg/data/common_test.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
package data
22

3+
import (
4+
"github.com/deis/workflow-manager-api/pkg/swagger/models"
5+
)
6+
37
const (
4-
clusterID = "testcluster"
5-
componentName = "testcomponent"
6-
componentDescription = "this is a component"
7-
version = "testversion"
8-
train = "stable"
9-
released = "2006-01-02T15:04:05Z"
10-
updateAvailable = "yup"
8+
clusterID = "testcluster"
9+
componentName = "testcomponent"
10+
version = "testversion"
11+
train = "stable"
12+
released = "2006-01-02T15:04:05Z"
1113
)
1214

1315
var (
14-
versionData = map[string]interface{}{
15-
"notes": "release notes",
16+
versionData = models.Data{
17+
Description: "release notes",
1618
}
19+
componentDescription = "this is a component"
20+
updateAvailable = "yup"
1721
)

pkg/data/component_and_train.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package data
33
import (
44
"fmt"
55

6-
"github.com/deis/workflow-manager/types"
6+
"github.com/deis/workflow-manager-api/pkg/swagger/models"
77
)
88

99
// ComponentAndTrain represents a component and its train. It is used in functions such as
@@ -14,7 +14,7 @@ type ComponentAndTrain struct {
1414
Train string
1515
}
1616

17-
func componentAndTrainFromComponentVersion(cv types.ComponentVersion) *ComponentAndTrain {
17+
func componentAndTrainFromComponentVersion(cv *models.ComponentVersion) *ComponentAndTrain {
1818
return &ComponentAndTrain{
1919
ComponentName: cv.Component.Name,
2020
Train: cv.Version.Train,

pkg/data/util.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ package data
33
import (
44
"encoding/json"
55
"github.com/deis/workflow-manager-api/pkg/swagger/models"
6-
"github.com/deis/workflow-manager/types"
76
sqlxTypes "github.com/jmoiron/sqlx/types"
87
"log"
98
)
109

11-
func parseJSONComponent(jTxt sqlxTypes.JSONText) (types.ComponentVersion, error) {
12-
ret := new(types.ComponentVersion)
10+
func parseJSONComponent(jTxt sqlxTypes.JSONText) (models.ComponentVersion, error) {
11+
ret := new(models.ComponentVersion)
1312
if err := json.Unmarshal(jTxt, ret); err != nil {
14-
return types.ComponentVersion{}, err
13+
return models.ComponentVersion{}, err
1514
}
1615
return *ret, nil
1716
}

pkg/data/util_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"testing"
66

77
"github.com/arschles/assert"
8-
"github.com/deis/workflow-manager/types"
8+
"github.com/deis/workflow-manager-api/pkg/swagger/models"
99
sqlxTypes "github.com/jmoiron/sqlx/types"
1010
)
1111

@@ -18,10 +18,10 @@ func TestParseJSONComponentFail(t *testing.T) {
1818
}
1919

2020
func TestParseJSONComponentSucc(t *testing.T) {
21-
cVer := types.ComponentVersion{
22-
Component: types.Component{Name: "test name", Description: "test description"},
23-
Version: types.Version{Train: "stable", Version: "test version", Released: "test release", Data: versionData},
24-
UpdateAvailable: "test update avail",
21+
cVer := models.ComponentVersion{
22+
Component: &models.Component{Name: "test name", Description: &componentDescription},
23+
Version: &models.Version{Train: "stable", Version: "test version", Released: "test release", Data: &versionData},
24+
UpdateAvailable: &updateAvailable,
2525
}
2626
b, err := json.Marshal(cVer)
2727
if err != nil {

0 commit comments

Comments
 (0)