aboutsummaryrefslogtreecommitdiff
path: root/cmd/kpod/common_test.go
blob: 663bc41e162e12091912c296fbad486e0f5e704c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main

import (
	"os/exec"
	"os/user"
	"testing"

	"flag"

	"github.com/urfave/cli"
)

func TestGetStore(t *testing.T) {
	t.Skip("FIX THIS!")

	//cmd/kpod/common_test.go:27: cannot use c (type *cli.Context) as type *libkpod.Config in argument to getStore

	// Make sure the tests are running as root
	skipTestIfNotRoot(t)

	set := flag.NewFlagSet("test", 0)
	globalSet := flag.NewFlagSet("test", 0)
	globalSet.String("root", "", "path to the root directory in which data, including images,  is stored")
	globalCtx := cli.NewContext(nil, globalSet, nil)
	command := cli.Command{Name: "imagesCommand"}
	c := cli.NewContext(nil, set, globalCtx)
	c.Command = command

	//_, err := getStore(c)
	//if err != nil {
	//t.Error(err)
	//}
}

func skipTestIfNotRoot(t *testing.T) {
	u, err := user.Current()
	if err != nil {
		t.Skip("Could not determine user.  Running without root may cause tests to fail")
	} else if u.Uid != "0" {
		t.Skip("tests will fail unless run as root")
	}
}

func pullTestImage(name string) error {
	cmd := exec.Command("crioctl", "image", "pull", name)
	err := cmd.Run()
	if err != nil {
		return err
	}
	return nil
}