github.com/artisanhe/tools@v1.0.1-0.20210607022958-19a8fef2eb04/docker/docker_compose_test.go (about)

     1  package docker
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  	"gopkg.in/yaml.v2"
     8  )
     9  
    10  func TestDockerCompose(t *testing.T) {
    11  	tt := assert.New(t)
    12  
    13  	d := DockerCompose{}
    14  
    15  	yaml.Unmarshal([]byte(`version: "2"
    16  
    17  services:
    18    web: 
    19      image: "test"
    20      environment:
    21        KEY_1: "2"
    22        KEY_2: "2"
    23  `), &d)
    24  
    25  	yaml.Unmarshal([]byte(`version: "2"
    26  
    27  services:
    28    add:
    29      image: "add"
    30    web: 
    31      image: "web"
    32      environment:
    33        KEY_1: "1"
    34        KEY_3: "1"
    35  `), &d)
    36  
    37  	tt.Equal(d.Services["web"].Environment, map[string]string{
    38  		"KEY_1": "1",
    39  		"KEY_2": "2",
    40  		"KEY_3": "1",
    41  	})
    42  }