Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
123 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package lbadd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package lbadd | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_newCommand(t *testing.T) { | ||
type args struct { | ||
cmd string | ||
} | ||
|
||
tests := []struct { | ||
name string | ||
args args | ||
want command | ||
}{ | ||
{ | ||
name: "unknown command", | ||
args: args{cmd: "uh oh"}, | ||
want: 0, | ||
}, | ||
{ | ||
name: "insert", | ||
args: args{cmd: "insert"}, | ||
want: 1, | ||
}, | ||
{ | ||
name: "select", | ||
args: args{cmd: "select"}, | ||
want: 2, | ||
}, | ||
{ | ||
name: "delete", | ||
args: args{cmd: "delete"}, | ||
want: 3, | ||
}, | ||
{ | ||
name: "mixed casing insert", | ||
args: args{cmd: "iNsErT"}, | ||
want: 1, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := newCommand(tt.args.cmd) | ||
assert.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} | ||
|
||
func Test_command_String(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
c command | ||
want string | ||
}{ | ||
{ | ||
name: "unknown", | ||
c: 0, | ||
want: "UNKNOWN", | ||
}, | ||
{ | ||
name: "insert", | ||
c: 1, | ||
want: "INSERT", | ||
}, | ||
{ | ||
name: "select", | ||
c: 2, | ||
want: "SELECT", | ||
}, | ||
{ | ||
name: "delete", | ||
c: 3, | ||
want: "DELETE", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := tt.c.String() | ||
assert.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,32 @@ | ||
package lbadd | ||
|
||
import "testing" | ||
|
||
func Test_executor_execute(t *testing.T) { | ||
type ( | ||
fields struct { | ||
db *db | ||
} | ||
args struct { | ||
instr instruction | ||
} | ||
) | ||
|
||
tests := []struct { | ||
name string | ||
fields fields | ||
args args | ||
wantErr bool | ||
}{ | ||
// TODO: Add test cases. | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
e := &executor{db: tt.fields.db} | ||
if err := e.execute(tt.args.instr); (err != nil) != tt.wantErr { | ||
t.Errorf("executor.execute() error = %v, wantErr %v", err, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters