mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-22 12:29:49 +00:00
Many cli and arch files were using the 'older style' fairly full Apache license text. The project standard is the shorter SPDX style. Convert them over. Fixes: #225 Signed-off-by: Graham whaley <graham.whaley@intel.com>
55 lines
1007 B
Go
55 lines
1007 B
Go
// Copyright (c) 2017 Intel Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
func TestVersion(t *testing.T) {
|
|
const testAppName = "foo"
|
|
const testAppVersion = "0.1.0"
|
|
|
|
resetCLIGlobals()
|
|
|
|
savedRuntimeVersionFunc := runtimeVersion
|
|
|
|
defer func() {
|
|
runtimeVersion = savedRuntimeVersionFunc
|
|
}()
|
|
|
|
runtimeVersion := func() string {
|
|
return testAppVersion
|
|
}
|
|
|
|
app := cli.NewApp()
|
|
ctx := cli.NewContext(app, nil, nil)
|
|
app.Name = testAppName
|
|
app.Version = runtimeVersion()
|
|
|
|
fn, ok := versionCLICommand.Action.(func(context *cli.Context) error)
|
|
assert.True(t, ok)
|
|
|
|
tmpfile, err := ioutil.TempFile("", "")
|
|
assert.NoError(t, err)
|
|
defer os.Remove(tmpfile.Name())
|
|
|
|
ctx.App.Writer = tmpfile
|
|
|
|
err = fn(ctx)
|
|
assert.NoError(t, err)
|
|
|
|
pattern := fmt.Sprintf("%s.*version.*%s", testAppName, testAppVersion)
|
|
err = grep(pattern, tmpfile.Name())
|
|
assert.NoError(t, err)
|
|
}
|