Skip to content

Commit

Permalink
Exists test
Browse files Browse the repository at this point in the history
Accidentally overwritten existing test.
  • Loading branch information
olivere committed Aug 2, 2015
1 parent 8647062 commit b54a46e
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion exists_test.go
Expand Up @@ -4,7 +4,9 @@

package elastic

import "testing"
import (
"testing"
)

func TestExists(t *testing.T) {
client := setupTestClientAndCreateIndexAndAddDocs(t) //, SetTraceLog(log.New(os.Stdout, "", 0)))
Expand All @@ -17,3 +19,34 @@ func TestExists(t *testing.T) {
t.Fatal("expected document to exist")
}
}

func TestExistsValidate(t *testing.T) {
client := setupTestClient(t)

// No index -> fail with error
res, err := NewExistsService(client).Type("tweet").Id("1").Do()
if err == nil {
t.Fatalf("expected Delete to fail without index name")
}
if res != false {
t.Fatalf("expected result to be false; got: %v", res)
}

// No type -> fail with error
res, err = NewExistsService(client).Index(testIndexName).Id("1").Do()
if err == nil {
t.Fatalf("expected Delete to fail without index name")
}
if res != false {
t.Fatalf("expected result to be false; got: %v", res)
}

// No id -> fail with error
res, err = NewExistsService(client).Index(testIndexName).Type("tweet").Do()
if err == nil {
t.Fatalf("expected Delete to fail without index name")
}
if res != false {
t.Fatalf("expected result to be false; got: %v", res)
}
}

0 comments on commit b54a46e

Please sign in to comment.