Skip to content

Commit

Permalink
Correct to tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
rytswd committed Jul 17, 2023
1 parent 2274d2e commit fde463d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestSimple(t *testing.T) {
// _ = clean

db.Prepare(t, `
// Comment can be placed based on SurrealQL syntax.
// Comment can be placed based on SurrealQL syntax.
// Dummy entry for database write testing.
CREATE x:x SET x = "X";
Expand All @@ -38,7 +38,7 @@ func TestSimple(t *testing.T) {
// SurrealDB will generate a random ID for this entry.
CREATE user SET name = "John";
CREATE user SET name = "Johnny";
`)
`)

type User struct {
Username string `json:"username,omitempty"`
Expand Down
50 changes: 25 additions & 25 deletions unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestUnmarshal(t *testing.T) {

prep := func(t testing.TB, db *surrealtest.SurrealDBTest) {
db.Prepare(t, `
// Comment can be placed based on SurrealQL syntax.
// Comment can be placed based on SurrealQL syntax.
// Dummy entry for database write testing
CREATE x:x SET x = "X";
Expand All @@ -35,7 +35,7 @@ func TestUnmarshal(t *testing.T) {
// SurrealDB will generate a random ID for this entry.
CREATE user:john SET name = "John";
CREATE user:johnny SET name = "Johnny";
`)
`)
}

cases := map[string]struct {
Expand Down Expand Up @@ -86,9 +86,9 @@ func TestUnmarshal(t *testing.T) {
interaction: func(db *surrealtest.SurrealDBTest) (interface{}, error) {
return db.Query(
`
CREATE user:j SET name = "J";
CREATE user:jo SET name = "Jo";
`, nil)
CREATE user:j SET name = "J";
CREATE user:jo SET name = "Jo";
`, nil)
},
wantData: []User{
{
Expand All @@ -105,22 +105,22 @@ func TestUnmarshal(t *testing.T) {
interaction: func(db *surrealtest.SurrealDBTest) (interface{}, error) {
return db.Query(
`
CREATE user:j SET name = "J";
CREATE user:j SET name = "J"; // conflict
CREATE user SET name = "John";
`, nil)
CREATE user:j SET name = "J";
CREATE user:j SET name = "J"; // conflict
CREATE user SET name = "John";
`, nil)
},
wantErrorMsg: "Database record `user:j` already exists",
},
"Transaction: success": {
interaction: func(db *surrealtest.SurrealDBTest) (interface{}, error) {
return db.Query(
`
BEGIN TRANSACTION;
CREATE user:j SET name = "J";
CREATE user:jo SET name = "Jo";
COMMIT TRANSACTION;
`, nil)
BEGIN TRANSACTION;
CREATE user:j SET name = "J";
CREATE user:jo SET name = "Jo";
COMMIT TRANSACTION;
`, nil)
},
wantData: []User{
{
Expand All @@ -137,24 +137,24 @@ func TestUnmarshal(t *testing.T) {
interaction: func(db *surrealtest.SurrealDBTest) (interface{}, error) {
return db.Query(
`
BEGIN TRANSACTION;
CREATE user:j SET name = "J";
CREATE user:j SET name = "J"; // conflict
CREATE user SET name = "John";
COMMIT TRANSACTION;
`, nil)
BEGIN TRANSACTION;
CREATE user:j SET name = "J";
CREATE user:j SET name = "J"; // conflict
CREATE user SET name = "John";
COMMIT TRANSACTION;
`, nil)
},
wantErrorMsg: "Database record `user:j` already exists",
},
"Transaction: canceled": {
interaction: func(db *surrealtest.SurrealDBTest) (interface{}, error) {
return db.Query(
`
BEGIN TRANSACTION;
CREATE user:j SET name = "J";
CREATE user SET name = "John";
CANCEL TRANSACTION;
`, nil)
BEGIN TRANSACTION;
CREATE user:j SET name = "J";
CREATE user SET name = "John";
CANCEL TRANSACTION;
`, nil)
},
wantErrorMsg: "cancelled transaction",
},
Expand Down

0 comments on commit fde463d

Please sign in to comment.