This repository has been archived by the owner on Mar 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
sqlfiddle_test.go
62 lines (52 loc) · 1.57 KB
/
sqlfiddle_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2018 The Xorm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sqlfiddle
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestFiddle_CreateSchema4Mysql(t *testing.T) {
fiddle := NewFiddle("")
res, err := fiddle.CreateSchema(Mysql5_6, `create table person(id int not null auto_increment,
name varchar(8),
birthday datetime,
constraint pk__person primary key(id));`)
assert.NoError(t, err)
fmt.Println(res)
ret, err := fiddle.RunSQL(Mysql5_6, res.Code, "select * from person;")
assert.NoError(t, err)
fmt.Println(ret)
ret, err = fiddle.RunSQL(Mysql5_6, res.Code, "select * from person1;")
assert.Error(t, err)
fmt.Println(err)
}
func TestFiddle_CreateSchema4Oracle(t *testing.T) {
fiddle := NewFiddle("")
res, err := fiddle.CreateSchema(Oracle11gR2, `create table table1(
id number(9) not null primary key,
a varchar2(40),
b varchar2(40),
c varchar2(40)
);`)
assert.NoError(t, err)
fmt.Println(res)
ret, err := fiddle.RunSQL(Oracle11gR2, res.Code, "select * from table1;")
assert.NoError(t, err)
fmt.Println(ret)
}
func TestFiddle_CreateSchema4MssSQL(t *testing.T) {
fiddle := NewFiddle("")
res, err := fiddle.CreateSchema(Oracle11gR2, `create table table1(
id int primary key,
a varchar(40),
b varchar(40),
c varchar(40)
);`)
assert.NoError(t, err)
fmt.Println(res)
ret, err := fiddle.RunSQL(Oracle11gR2, res.Code, "select * from table1;")
assert.NoError(t, err)
fmt.Println(ret)
}