github.com/klaytn/klaytn@v1.12.1/storage/database/interface_test.go (about) 1 // Modifications Copyright 2020 The klaytn Authors 2 // Copyright 2015 The go-ethereum Authors 3 // This file is part of the go-ethereum library. 4 // 5 // The go-ethereum library is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Lesser General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // The go-ethereum library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Lesser General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public License 16 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 17 18 package database 19 20 import ( 21 "testing" 22 23 "github.com/stretchr/testify/assert" 24 ) 25 26 func TestDBType_ToValid(t *testing.T) { 27 validDBType := []DBType{LevelDB, BadgerDB, MemoryDB, DynamoDB} 28 29 // check acceptable dbtype values 30 acceptableDBTypes := []DBType{ 31 "LevelDB", "leveldb", "levelDB", "LevelDB", 32 "BadgerDB", "badgerdb", "Badgerdb", "badgerDB", 33 "MemoryDB", "memorydb", "Memorydb", "memoryDB", 34 "DynamoDBS3", "dynamodbs3", "Dynamodbs3", "DynamodbS3", "dynamodbS3", 35 } 36 37 for _, dbtype := range acceptableDBTypes { 38 newType := dbtype.ToValid() 39 assert.Contains(t, validDBType, newType, "dbtype not acceptable: "+dbtype) 40 } 41 42 // check not acceptable dbtype values 43 notAcceptableDBTypes := []DBType{ 44 "level", "ldb", "badger", "memory", 45 "dynamo", "dynamodb", "dynamos3", "ddb", "ShardedDB", 46 } 47 48 for _, dbtype := range notAcceptableDBTypes { 49 newType := dbtype.ToValid() 50 assert.Equal(t, DBType(""), newType, "dbtype should not acceptable:"+dbtype) 51 } 52 }