mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-22 20:39:41 +00:00
Add spec command that generates a basic config.json for kata. fixes #188 Signed-off-by: Ruidong Cao <caoruidong@huawei.com> Signed-off-by: Ruidong <caoruidong@huawei.com>
36 lines
714 B
Go
36 lines
714 B
Go
// Copyright (c) 2018 Huawei Corporation.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
func TestSpecCliAction(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
actionFunc, ok := specCLICommand.Action.(func(context *cli.Context) error)
|
|
assert.True(ok)
|
|
|
|
flagSet := flag.NewFlagSet("flag", flag.ContinueOnError)
|
|
ctx := cli.NewContext(&cli.App{}, flagSet, nil)
|
|
defer os.Remove(specConfig)
|
|
err := actionFunc(ctx)
|
|
assert.NoError(err)
|
|
|
|
pattern := "gid=5"
|
|
patternRootless := "uidMappings"
|
|
err = grep(pattern, specConfig)
|
|
assert.NoError(err)
|
|
err = grep(patternRootless, specConfig)
|
|
assert.Error(err)
|
|
}
|