github.com/bdwilliams/libcompose@v0.3.1-0.20160826154243-d81a9bdacff0/config/convert_test.go (about) 1 package config 2 3 import ( 4 "reflect" 5 "testing" 6 7 "github.com/docker/libcompose/yaml" 8 ) 9 10 func TestBuild(t *testing.T) { 11 v2Services, err := ConvertServices(map[string]*ServiceConfigV1{ 12 "test": { 13 Build: ".", 14 Dockerfile: "Dockerfile", 15 }, 16 }) 17 if err != nil { 18 t.Fatal(err) 19 } 20 21 v2Config := v2Services["test"] 22 23 expectedBuild := yaml.Build{ 24 Context: ".", 25 Dockerfile: "Dockerfile", 26 } 27 28 if !reflect.DeepEqual(v2Config.Build, expectedBuild) { 29 t.Fatal("Failed to convert build", v2Config.Build) 30 } 31 } 32 33 func TestLogging(t *testing.T) { 34 v2Services, err := ConvertServices(map[string]*ServiceConfigV1{ 35 "test": { 36 LogDriver: "json-file", 37 LogOpt: map[string]string{ 38 "key": "value", 39 }, 40 }, 41 }) 42 if err != nil { 43 t.Fatal(err) 44 } 45 46 v2Config := v2Services["test"] 47 48 expectedLogging := Log{ 49 Driver: "json-file", 50 Options: map[string]string{ 51 "key": "value", 52 }, 53 } 54 55 if !reflect.DeepEqual(v2Config.Logging, expectedLogging) { 56 t.Fatal("Failed to convert logging", v2Config.Logging) 57 } 58 } 59 60 func TestNetworkMode(t *testing.T) { 61 v2Services, err := ConvertServices(map[string]*ServiceConfigV1{ 62 "test": { 63 Net: "host", 64 }, 65 }) 66 if err != nil { 67 t.Fatal(err) 68 } 69 70 v2Config := v2Services["test"] 71 72 if v2Config.NetworkMode != "host" { 73 t.Fatal("Failed to convert network mode", v2Config.NetworkMode) 74 } 75 }