2018-02-07 23:25:50 +00:00
|
|
|
package daemon // import "github.com/docker/docker/daemon"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
containertypes "github.com/docker/docker/api/types/container"
|
|
|
|
"github.com/docker/docker/container"
|
|
|
|
"github.com/docker/docker/daemon/config"
|
2020-02-07 13:39:24 +00:00
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
is "gotest.tools/v3/assert/cmp"
|
2018-02-07 23:25:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetInspectData(t *testing.T) {
|
|
|
|
c := &container.Container{
|
|
|
|
ID: "inspect-me",
|
|
|
|
HostConfig: &containertypes.HostConfig{},
|
|
|
|
State: container.NewState(),
|
2022-05-10 19:59:00 +00:00
|
|
|
ExecCommands: container.NewExecStore(),
|
2018-02-07 23:25:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
d := &Daemon{
|
|
|
|
linkIndex: newLinkIndex(),
|
|
|
|
configStore: &config.Config{},
|
|
|
|
}
|
2023-04-13 10:12:51 +00:00
|
|
|
if d.UsesSnapshotter() {
|
|
|
|
t.Skip("does not apply to containerd snapshotters, which don't have RWLayer set")
|
|
|
|
}
|
2018-02-07 23:25:50 +00:00
|
|
|
_, err := d.getInspectData(c)
|
2023-04-13 10:12:51 +00:00
|
|
|
assert.Check(t, is.ErrorContains(err, "RWLayer of container inspect-me is unexpectedly nil"))
|
2018-02-07 23:25:50 +00:00
|
|
|
|
|
|
|
c.Dead = true
|
|
|
|
_, err = d.getInspectData(c)
|
2018-03-13 19:28:34 +00:00
|
|
|
assert.Check(t, err)
|
2018-02-07 23:25:50 +00:00
|
|
|
}
|