github.com/dolthub/go-mysql-server@v0.18.0/sql/rowexec/show_create_database_test.go (about) 1 // Copyright 2020-2021 Dolthub, Inc. 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 rowexec 16 17 import ( 18 "testing" 19 20 "github.com/stretchr/testify/require" 21 22 "github.com/dolthub/go-mysql-server/sql" 23 "github.com/dolthub/go-mysql-server/sql/plan" 24 ) 25 26 func TestShowCreateDatabase(t *testing.T) { 27 require := require.New(t) 28 29 node := plan.NewShowCreateDatabase(sql.UnresolvedDatabase("foo"), true) 30 ctx := sql.NewEmptyContext() 31 iter, err := DefaultBuilder.Build(ctx, node, nil) 32 require.NoError(err) 33 34 rows, err := sql.RowIterToRows(ctx, iter) 35 require.NoError(err) 36 37 require.Equal([]sql.Row{ 38 {"foo", "CREATE DATABASE /*!32312 IF NOT EXISTS*/ `foo` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_bin */"}, 39 }, rows) 40 41 node = plan.NewShowCreateDatabase(sql.UnresolvedDatabase("foo"), false) 42 ctx = sql.NewEmptyContext() 43 iter, err = DefaultBuilder.Build(ctx, node, nil) 44 require.NoError(err) 45 46 rows, err = sql.RowIterToRows(ctx, iter) 47 require.NoError(err) 48 49 require.Equal([]sql.Row{ 50 {"foo", "CREATE DATABASE `foo` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_bin */"}, 51 }, rows) 52 }