Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
araddon committed Oct 31, 2017
1 parent 32bec33 commit 2c89e34
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 38 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backends/cassandra/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@



Cassandra Data source
Cassandra Source
--------------------------------------

Provides SQL Access to Cassandra
Expand Down
6 changes: 3 additions & 3 deletions backends/cassandra/cass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
DbConn = "root@tcp(127.0.0.1:13307)/datauxtest?parseTime=true"
loadTestDataOnce sync.Once
now = time.Now()
expectedRowCt = 105
testServicesRunning bool
cassHost *string = flag.String("casshost", "localhost:9042", "Cassandra Host")
session *gocql.Session
Expand All @@ -38,7 +39,6 @@ var (
)

func init() {

cass := os.Getenv("CASSANDRA_HOST")
if len(cass) > 0 {
*cassHost = cass
Expand Down Expand Up @@ -182,7 +182,7 @@ func loadTestData(t *testing.T) {
VALUES (?, ? , ? , ? , ? , ? , ? , ? , ? , ?)
`, article.ValueI()...).Exec()
//u.Infof("insert: %v", article.Row())
assert.True(t, err == nil, "must put but got err: %v", err)
assert.Equal(t, nil, err)
}
/*
// Now we are going to write the embeded?
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestShowTables(t *testing.T) {
Sql: "show tables;",
ExpectRowCt: 3,
ValidateRowData: func() {
//u.Infof("%+v", data)
u.Infof("%+v", data)
assert.True(t, data.Table != "", "%v", data)
if data.Table == strings.ToLower("article") {
found = true
Expand Down
4 changes: 0 additions & 4 deletions backends/cassandra/cassandra.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
# etcd servers
etcd = ["http://localhost:2379"]

# Nats.io GnatsD servers
nats = [ "nats://localhost:4222" ]


# frontend is inbound tcp connection listener (only mysql currently supported)
# - we don't bind to 3306 because that is mysql's
#
Expand Down
52 changes: 24 additions & 28 deletions backends/files/filesource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,21 @@ export TESTINT=1
*/
var (
testServicesRunning bool
localconfig = &cloudstorage.CloudStoreContext{
LogggingContext: "unittest",
TokenSource: cloudstorage.LocalFileSource,
LocalFS: "tables/",
TmpDir: "/tmp/localcache",
}
gcsIntconfig = &cloudstorage.CloudStoreContext{
LogggingContext: "dataux-test",
TokenSource: cloudstorage.GCEDefaultOAuthToken,
Project: "lytics-dev",
Bucket: "lytics-dataux-tests",
TmpDir: "/tmp/localcache",
}
)

var localconfig = &cloudstorage.CloudStoreContext{
LogggingContext: "unittest",
TokenSource: cloudstorage.LocalFileSource,
LocalFS: "tables/",
TmpDir: "/tmp/localcache",
}

var gcsIntconfig = &cloudstorage.CloudStoreContext{
LogggingContext: "dataux-test",
TokenSource: cloudstorage.GCEDefaultOAuthToken,
Project: "lytics-dev",
Bucket: "lytics-dataux-tests",
TmpDir: "/tmp/localcache",
}

func init() {
u.SetupLogging("debug")
u.SetColorOutput()
Expand Down Expand Up @@ -112,7 +110,6 @@ func clearStore(t *testing.T, store cloudstorage.Store) {
}

func validateQuerySpec(t testing.TB, testSpec tu.QuerySpec) {

switch tt := t.(type) {
case *testing.T:
RunTestServer(tt)
Expand All @@ -122,18 +119,18 @@ func validateQuerySpec(t testing.TB, testSpec tu.QuerySpec) {

func createTestData(t *testing.T) {
store, err := createLocalStore()
assert.True(t, err == nil)
assert.Equal(t, nil, err)
//clearStore(t, store)
//defer clearStore(t, store)

//Create a new object and write to it.
// Create a new object and write to it.
obj, err := store.NewObject("tables/article/article1.csv")
if err != nil {
return // already created
}
assert.True(t, err == nil)
assert.Equal(t, nil, err)
f, err := obj.Open(cloudstorage.ReadWrite)
assert.True(t, err == nil)
assert.Equal(t, nil, err)

w := bufio.NewWriter(f)
w.WriteString(tu.Articles[0].Header())
Expand Down Expand Up @@ -166,15 +163,14 @@ func createTestData(t *testing.T) {

//Read the object back out of the cloud storage.
obj2, err := store.Get("tables/article/article1.csv")
assert.True(t, err == nil)
assert.Equal(t, nil, err)

f2, err := obj2.Open(cloudstorage.ReadOnly)
assert.True(t, err == nil)
assert.Equal(t, nil, err)

bytes, err := ioutil.ReadAll(f2)
assert.True(t, err == nil)

assert.True(t, tu.ArticleCsv == string(bytes), "Wanted equal got %s", bytes)
assert.Equal(t, nil, err)
assert.Equal(t, tu.ArticleCsv, string(bytes), "Wanted equal got %s", bytes)
}

func TestShowTables(t *testing.T) {
Expand Down Expand Up @@ -220,11 +216,11 @@ func TestSelectFilesList(t *testing.T) {
func TestSelectStar(t *testing.T) {
RunTestServer(t)
db, err := sql.Open("mysql", "root@tcp(127.0.0.1:13307)/datauxtest")
assert.True(t, err == nil)
assert.Equal(t, nil, err)
rows, err := db.Query("select * from article;")
assert.True(t, err == nil, "did not want err but got %v", err)
assert.Equal(t, nil, err)
cols, _ := rows.Columns()
assert.True(t, len(cols) == 7, "want 7 cols but got %v", cols)
assert.Equal(t, 12, len(cols), "want 12 cols but got %v", len(cols))
assert.True(t, rows.Next(), "must get next row but couldn't")
readCols := make([]interface{}, len(cols))
writeCols := make([]string, len(cols))
Expand Down

0 comments on commit 2c89e34

Please sign in to comment.