github.com/bartle-stripe/trillian@v1.2.1/integration/maptest/map_test.go (about) 1 // Copyright 2017 Google Inc. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package maptest 16 17 import ( 18 "context" 19 "flag" 20 "log" 21 "testing" 22 23 "github.com/google/trillian/storage/testdb" 24 "github.com/google/trillian/testonly/integration" 25 26 _ "github.com/google/trillian/merkle/coniks" 27 _ "github.com/google/trillian/merkle/maphasher" 28 ) 29 30 var server = flag.String("map_rpc_server", "", "Server address:port") 31 32 func TestMapIntegration(t *testing.T) { 33 34 ctx := context.Background() 35 var env *integration.MapEnv 36 var err error 37 if *server == "" { 38 if !testdb.MySQLAvailable() { 39 t.Skip("Skipping map integration test, MySQL not available") 40 } 41 env, err = integration.NewMapEnv(ctx) 42 } else { 43 env, err = integration.NewMapEnvFromConn(*server) 44 } 45 if err != nil { 46 log.Fatalf("Could not create MapEnv: %v", err) 47 } 48 defer env.Close() 49 50 for _, test := range AllTests { 51 t.Run(test.Name, func(t *testing.T) { 52 test.Fn(ctx, t, env.Admin, env.Map) 53 }) 54 } 55 }