Add test for determining the container dumper type

This commit is contained in:
kolaente 2021-08-18 22:38:59 +02:00
parent 02ba460b3a
commit 54c22ee13b
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 40 additions and 0 deletions

40
dump_test.go Normal file
View File

@ -0,0 +1,40 @@
package main
import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"reflect"
"testing"
)
func TestNewDumperFromContainer(t *testing.T) {
tests := []struct {
name string
container *types.ContainerJSON
want string
}{
{
name: "mysql",
container: &types.ContainerJSON{Config: &container.Config{Image: "mysql"}},
want: "MysqlDumper",
},
{
name: "mariadb",
container: &types.ContainerJSON{Config: &container.Config{Image: "mysql"}},
want: "MysqlDumper",
},
{
name: "postgres",
container: &types.ContainerJSON{Config: &container.Config{Image: "postgres"}},
want: "PostgresDumper",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := NewDumperFromContainer(tt.container)
if reflect.TypeOf(got).Elem().Name() != tt.want {
t.Errorf("NewDumperFromContainer() is %s, want %s", got, tt.want)
}
})
}
}