github.com/containerd/nerdctl@v1.7.7/cmd/nerdctl/compose_pull_linux_test.go (about)

     1  /*
     2     Copyright The containerd Authors.
     3  
     4     Licensed under the Apache License, Version 2.0 (the "License");
     5     you may not use this file except in compliance with the License.
     6     You may obtain a copy of the License at
     7  
     8         http://www.apache.org/licenses/LICENSE-2.0
     9  
    10     Unless required by applicable law or agreed to in writing, software
    11     distributed under the License is distributed on an "AS IS" BASIS,
    12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13     See the License for the specific language governing permissions and
    14     limitations under the License.
    15  */
    16  
    17  package main
    18  
    19  import (
    20  	"fmt"
    21  	"testing"
    22  
    23  	"github.com/containerd/nerdctl/pkg/testutil"
    24  )
    25  
    26  func TestComposePullWithService(t *testing.T) {
    27  	base := testutil.NewBase(t)
    28  	var dockerComposeYAML = fmt.Sprintf(`
    29  version: '3.1'
    30  
    31  services:
    32  
    33    wordpress:
    34      image: %s
    35      ports:
    36        - 8080:80
    37      environment:
    38        WORDPRESS_DB_HOST: db
    39        WORDPRESS_DB_USER: exampleuser
    40        WORDPRESS_DB_PASSWORD: examplepass
    41        WORDPRESS_DB_NAME: exampledb
    42      volumes:
    43        - wordpress:/var/www/html
    44  
    45    db:
    46      image: %s
    47      environment:
    48        MYSQL_DATABASE: exampledb
    49        MYSQL_USER: exampleuser
    50        MYSQL_PASSWORD: examplepass
    51        MYSQL_RANDOM_ROOT_PASSWORD: '1'
    52      volumes:
    53        - db:/var/lib/mysql
    54  
    55  volumes:
    56    wordpress:
    57    db:
    58  `, testutil.WordpressImage, testutil.MariaDBImage)
    59  
    60  	comp := testutil.NewComposeDir(t, dockerComposeYAML)
    61  	defer comp.CleanUp()
    62  	projectName := comp.ProjectName()
    63  	t.Logf("projectName=%q", projectName)
    64  
    65  	base.ComposeCmd("-f", comp.YAMLFullPath(), "pull", "db").AssertNoOut("wordpress")
    66  }