We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
func SetupTests(t *testing.T) *gorm.DB { mocket.Catcher.Register() mocket.Catcher.Logging = true db, err := gorm.Open(mocket.DriverName, "connection_string") if err != nil { t.Fatalf(err.Error()) } return db } func TestInsertStoragePool(t *testing.T) { cases := []struct { givenPool StoragePool wantedError error }{ { // happy path givenPool: StoragePool{ Name: "POOL1", PoolId: "1", Type: "NetworkFilesystem", Volumes: []Volume{ { Name: "VOL01", StorageId: "1", Type: "ROOT", VolumeId: "1", }, }, }, wantedError: nil, }, } for _, c := range cases { db := SetupTests(t) db.LogMode(true) reply := []map[string]interface{}{{"id": 5}} mocket.Catcher.Reset().NewMock().WithQuery("INSERT INTO \"storage_pools\"").WithID(int64(5)).WithArgs(c.givenPool).WithReply(reply) err := InsertStoragePool(db, &c.givenPool) if err != nil { t.Error(err) } fmt.Fprintf(os.Stderr, "\nPOOLID=%d\n", c.givenPool.ID) } }
What is this testing?
According to go test, this test succeeds with flying colors.
The text was updated successfully, but these errors were encountered:
I found something similar, for testing set the expected query to just UPDATE while the underlying query is an INSERT statement. the test still passes.
UPDATE
INSERT
Sorry, something went wrong.
No branches or pull requests
What is this testing?
According to go test, this test succeeds with flying colors.
The text was updated successfully, but these errors were encountered: