Skip to content

Commit 5a2120b

Browse files
committed
Update version
1 parent 1f0225e commit 5a2120b

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ Create MYSQL dumps in Go without the `mysqldump` CLI as a dependancy.
33

44
[![GoDoc](https://godoc.org/github.com/JamesStewy/go-mysqldump?status.svg)](https://godoc.org/github.com/JamesStewy/go-mysqldump)
55
[![Build Status](https://travis-ci.org/JamesStewy/go-mysqldump.svg?branch=master)](https://travis-ci.org/JamesStewy/go-mysqldump)
6-

dump.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type dump struct {
2323
CompleteTime string
2424
}
2525

26-
const version = "0.1.1"
26+
const version = "0.2.0"
2727

2828
const tmpl = `-- Go SQL Dump {{ .DumpVersion }}
2929
--

dump_test.go

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package mysqldump
22

33
import (
4-
"testing"
54
"github.com/DATA-DOG/go-sqlmock"
6-
"reflect"
75
"io/ioutil"
86
"os"
7+
"reflect"
98
"strings"
9+
"testing"
1010
)
1111

1212
func TestGetTablesOk(t *testing.T) {
@@ -18,12 +18,12 @@ func TestGetTablesOk(t *testing.T) {
1818
defer db.Close()
1919

2020
rows := sqlmock.NewRows([]string{"Tables_in_Testdb"}).
21-
AddRow("Test_Table_1",).
21+
AddRow("Test_Table_1").
2222
AddRow("Test_Table_2")
2323

2424
mock.ExpectQuery("^SHOW TABLES$").WillReturnRows(rows)
2525

26-
result, err := getTables(db);
26+
result, err := getTables(db)
2727
if err != nil {
2828
t.Errorf("error was not expected while updating stats: %s", err)
2929
}
@@ -55,7 +55,7 @@ func TestGetTablesNil(t *testing.T) {
5555

5656
mock.ExpectQuery("^SHOW TABLES$").WillReturnRows(rows)
5757

58-
result, err := getTables(db);
58+
result, err := getTables(db)
5959
if err != nil {
6060
t.Errorf("error was not expected while updating stats: %s", err)
6161
}
@@ -81,11 +81,11 @@ func TestGetServerVersionOk(t *testing.T) {
8181
defer db.Close()
8282

8383
rows := sqlmock.NewRows([]string{"Version()"}).
84-
AddRow("test_version",)
84+
AddRow("test_version")
8585

8686
mock.ExpectQuery("^SELECT version()").WillReturnRows(rows)
8787

88-
result, err := getServerVersion(db);
88+
result, err := getServerVersion(db)
8989
if err != nil {
9090
t.Errorf("error was not expected while updating stats: %s", err)
9191
}
@@ -111,11 +111,11 @@ func TestCreateTableSQLOk(t *testing.T) {
111111
defer db.Close()
112112

113113
rows := sqlmock.NewRows([]string{"Table", "Create Table"}).
114-
AddRow("Test_Table", "CREATE TABLE 'Test_Table' (`id` int(11) NOT NULL AUTO_INCREMENT,`s` char(60) DEFAULT NULL, PRIMARY KEY (`id`))ENGINE=InnoDB DEFAULT CHARSET=latin1",)
114+
AddRow("Test_Table", "CREATE TABLE 'Test_Table' (`id` int(11) NOT NULL AUTO_INCREMENT,`s` char(60) DEFAULT NULL, PRIMARY KEY (`id`))ENGINE=InnoDB DEFAULT CHARSET=latin1")
115115

116116
mock.ExpectQuery("^SHOW CREATE TABLE Test_Table$").WillReturnRows(rows)
117117

118-
result, err := createTableSQL(db, "Test_Table");
118+
result, err := createTableSQL(db, "Test_Table")
119119

120120
if err != nil {
121121
t.Errorf("error was not expected while updating stats: %s", err)
@@ -133,7 +133,6 @@ func TestCreateTableSQLOk(t *testing.T) {
133133
}
134134
}
135135

136-
137136
func TestCreateTableValuesOk(t *testing.T) {
138137
db, mock, err := sqlmock.New()
139138
if err != nil {
@@ -148,7 +147,7 @@ func TestCreateTableValuesOk(t *testing.T) {
148147

149148
mock.ExpectQuery("^SELECT (.+) FROM test$").WillReturnRows(rows)
150149

151-
result, err := createTableValues(db, "test");
150+
result, err := createTableValues(db, "test")
152151
if err != nil {
153152
t.Errorf("error was not expected while updating stats: %s", err)
154153
}
@@ -179,7 +178,7 @@ func TestCreateTableValuesNil(t *testing.T) {
179178

180179
mock.ExpectQuery("^SELECT (.+) FROM test$").WillReturnRows(rows)
181180

182-
result, err := createTableValues(db, "test");
181+
result, err := createTableValues(db, "test")
183182
if err != nil {
184183
t.Errorf("error was not expected while updating stats: %s", err)
185184
}
@@ -205,17 +204,16 @@ func TestCreateTableOk(t *testing.T) {
205204
defer db.Close()
206205

207206
createTableRows := sqlmock.NewRows([]string{"Table", "Create Table"}).
208-
AddRow("Test_Table", "CREATE TABLE 'Test_Table' (`id` int(11) NOT NULL AUTO_INCREMENT,`s` char(60) DEFAULT NULL, PRIMARY KEY (`id`))ENGINE=InnoDB DEFAULT CHARSET=latin1",)
207+
AddRow("Test_Table", "CREATE TABLE 'Test_Table' (`id` int(11) NOT NULL AUTO_INCREMENT,`s` char(60) DEFAULT NULL, PRIMARY KEY (`id`))ENGINE=InnoDB DEFAULT CHARSET=latin1")
209208

210209
createTableValueRows := sqlmock.NewRows([]string{"id", "email", "name"}).
211210
AddRow(1, nil, "Test Name 1").
212211
AddRow(2, "[email protected]", "Test Name 2")
213212

214-
215213
mock.ExpectQuery("^SHOW CREATE TABLE Test_Table$").WillReturnRows(createTableRows)
216214
mock.ExpectQuery("^SELECT (.+) FROM Test_Table$").WillReturnRows(createTableValueRows)
217215

218-
result, err := createTable(db, "Test_Table");
216+
result, err := createTable(db, "Test_Table")
219217
if err != nil {
220218
t.Errorf("error was not expected while updating stats: %s", err)
221219
}
@@ -226,8 +224,8 @@ func TestCreateTableOk(t *testing.T) {
226224
}
227225

228226
expectedResult := &table{
229-
Name:"Test_Table",
230-
SQL: "CREATE TABLE 'Test_Table' (`id` int(11) NOT NULL AUTO_INCREMENT,`s` char(60) DEFAULT NULL, PRIMARY KEY (`id`))ENGINE=InnoDB DEFAULT CHARSET=latin1",
227+
Name: "Test_Table",
228+
SQL: "CREATE TABLE 'Test_Table' (`id` int(11) NOT NULL AUTO_INCREMENT,`s` char(60) DEFAULT NULL, PRIMARY KEY (`id`))ENGINE=InnoDB DEFAULT CHARSET=latin1",
231229
Values: "('1','','Test Name 1'),('2','[email protected]','Test Name 2')",
232230
}
233231

@@ -249,13 +247,13 @@ func TestDumpOk(t *testing.T) {
249247
defer db.Close()
250248

251249
showTablesRows := sqlmock.NewRows([]string{"Tables_in_Testdb"}).
252-
AddRow("Test_Table",)
250+
AddRow("Test_Table")
253251

254252
serverVersionRows := sqlmock.NewRows([]string{"Version()"}).
255-
AddRow("test_version",)
253+
AddRow("test_version")
256254

257255
createTableRows := sqlmock.NewRows([]string{"Table", "Create Table"}).
258-
AddRow("Test_Table", "CREATE TABLE 'Test_Table' (`id` int(11) NOT NULL AUTO_INCREMENT,`email` char(60) DEFAULT NULL, `name` char(60), PRIMARY KEY (`id`))ENGINE=InnoDB DEFAULT CHARSET=latin1",)
256+
AddRow("Test_Table", "CREATE TABLE 'Test_Table' (`id` int(11) NOT NULL AUTO_INCREMENT,`email` char(60) DEFAULT NULL, `name` char(60), PRIMARY KEY (`id`))ENGINE=InnoDB DEFAULT CHARSET=latin1")
259257

260258
createTableValueRows := sqlmock.NewRows([]string{"id", "email", "name"}).
261259
AddRow(1, nil, "Test Name 1").
@@ -266,11 +264,10 @@ func TestDumpOk(t *testing.T) {
266264
mock.ExpectQuery("^SHOW CREATE TABLE Test_Table$").WillReturnRows(createTableRows)
267265
mock.ExpectQuery("^SELECT (.+) FROM Test_Table$").WillReturnRows(createTableValueRows)
268266

269-
270267
dumper := &Dumper{
271-
db:db,
268+
db: db,
272269
format: "test_format",
273-
dir: "/tmp/",
270+
dir: "/tmp/",
274271
}
275272

276273
path, err := dumper.Dump()
@@ -291,8 +288,7 @@ func TestDumpOk(t *testing.T) {
291288

292289
result := strings.Replace(strings.Split(string(f), "-- Dump completed")[0], "`", "\\", -1)
293290

294-
295-
expected := `-- Go SQL Dump 0.1.1
291+
expected := `-- Go SQL Dump ` + version + `
296292
--
297293
-- ------------------------------------------------------
298294
-- Server version test_version
@@ -320,4 +316,3 @@ UNLOCK TABLES;
320316
t.Fatalf("expected %#v, got %#v", expected, result)
321317
}
322318
}
323-

0 commit comments

Comments
 (0)