github.com/willyham/dosa@v2.3.1-0.20171024181418-1e446d37ee71+incompatible/connectors/devnull/devnull_test.go (about) 1 // Copyright (c) 2017 Uber Technologies, Inc. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 package devnull_test 22 23 import ( 24 "context" 25 "testing" 26 27 "github.com/stretchr/testify/assert" 28 "github.com/uber-go/dosa" 29 "github.com/uber-go/dosa/connectors/devnull" 30 ) 31 32 var sut = devnull.Connector{} 33 34 var ctx = context.Background() 35 36 var ( 37 testInfo = &dosa.EntityInfo{ 38 Ref: &dosa.SchemaRef{ 39 Scope: "testScope", 40 NamePrefix: "testPrefix", 41 EntityName: "testEntityName", 42 }, 43 Def: &dosa.EntityDefinition{}, 44 } 45 testConditions = make(map[string][]*dosa.Condition) 46 testPairs = dosa.FieldNameValuePair{} 47 testValues = make(map[string]dosa.FieldValue) 48 testMultiValues = make([]map[string]dosa.FieldValue, 1) 49 ) 50 51 func TestDevNull_CreateIfNotExists(t *testing.T) { 52 assert.NoError(t, sut.CreateIfNotExists(ctx, testInfo, testValues)) 53 } 54 55 func TestDevNull_Read(t *testing.T) { 56 minimumFields := make([]string, 1) 57 val, err := sut.Read(ctx, testInfo, testValues, minimumFields) 58 assert.Nil(t, val) 59 assert.Error(t, err) 60 } 61 62 func TestDevNull_MultiRead(t *testing.T) { 63 minimumFields := make([]string, 1) 64 v, e := sut.MultiRead(ctx, testInfo, testMultiValues, minimumFields) 65 assert.NotNil(t, v) 66 assert.Nil(t, e) 67 } 68 69 func TestDevNull_Upsert(t *testing.T) { 70 err := sut.Upsert(ctx, testInfo, testValues) 71 assert.Nil(t, err) 72 } 73 74 func TestDevNull_MultiUpsert(t *testing.T) { 75 errs, err := sut.MultiUpsert(ctx, testInfo, testMultiValues) 76 assert.NotNil(t, errs) 77 assert.Nil(t, err) 78 } 79 80 func TestDevNull_Remove(t *testing.T) { 81 err := sut.Remove(ctx, testInfo, testValues) 82 assert.NoError(t, err) 83 } 84 85 func TestDevNull_RemoveRange(t *testing.T) { 86 err := sut.RemoveRange(ctx, testInfo, testConditions) 87 assert.NoError(t, err) 88 } 89 90 func TestDevNull_MultiRemove(t *testing.T) { 91 errs, err := sut.MultiRemove(ctx, testInfo, testMultiValues) 92 assert.NotNil(t, errs) 93 assert.Nil(t, err) 94 } 95 96 func TestDevNull_Range(t *testing.T) { 97 minimumFields := make([]string, 1) 98 vals, _, err := sut.Range(ctx, testInfo, testConditions, minimumFields, "", 0) 99 assert.Nil(t, vals) 100 assert.Error(t, err) 101 } 102 103 func TestDevNull_Scan(t *testing.T) { 104 minimumFields := make([]string, 1) 105 vals, _, err := sut.Scan(ctx, testInfo, minimumFields, "", 0) 106 assert.Nil(t, vals) 107 assert.Error(t, err) 108 } 109 110 func TestDevNull_CheckSchema(t *testing.T) { 111 defs := make([]*dosa.EntityDefinition, 4) 112 versions, err := sut.CheckSchema(ctx, "testScope", "testPrefix", defs) 113 assert.NotNil(t, versions) 114 assert.NoError(t, err) 115 } 116 117 func TestDevNull_CheckSchemaStatus(t *testing.T) { 118 status, err := sut.CheckSchemaStatus(ctx, "testScope", "testPrefix", int32(1)) 119 assert.NotNil(t, status) 120 assert.NoError(t, err) 121 } 122 123 func TestDevNull_UpsertSchema(t *testing.T) { 124 defs := make([]*dosa.EntityDefinition, 4) 125 status, err := sut.UpsertSchema(ctx, "testScope", "testPrefix", defs) 126 assert.NotNil(t, status) 127 assert.NoError(t, err) 128 } 129 130 func TestDevNull_CreateScope(t *testing.T) { 131 assert.NoError(t, sut.CreateScope(ctx, "")) 132 } 133 134 func TestDevNull_TruncateScope(t *testing.T) { 135 assert.NoError(t, sut.TruncateScope(ctx, "")) 136 } 137 138 func TestDevNull_DropScope(t *testing.T) { 139 assert.NoError(t, sut.DropScope(ctx, "")) 140 } 141 142 func TestDevNull_ScopeExists(t *testing.T) { 143 e, err := sut.ScopeExists(ctx, "") 144 assert.NoError(t, err) 145 assert.True(t, e) 146 } 147 148 func TestDevNull_Shutdown(t *testing.T) { 149 assert.Nil(t, sut.Shutdown()) 150 }