Skip to content

Commit

Permalink
virtcontainers: fix unit tests
Browse files Browse the repository at this point in the history
Use noopAgent in unit tests to add online fake resources.
Fix unit tests according with new changes introduced recently.

fixes kata-containers#192

Signed-off-by: Julio Montes <[email protected]>
  • Loading branch information
Julio Montes committed Apr 5, 2018
1 parent bc83bf0 commit 92fa5e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion virtcontainers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,7 @@ func TestEnterContainerFailingContNotStarted(t *testing.T) {
cmd := newBasicTestCmd()

_, c, _, err = EnterContainer(p.ID(), contID, cmd)
if c != nil || err == nil {
if c == nil || err != nil {
t.Fatal()
}
}
Expand Down
12 changes: 10 additions & 2 deletions virtcontainers/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ func TestContainerAddDriveDir(t *testing.T) {
id: testPodID,
storage: fs,
hypervisor: &mockHypervisor{},
agent: &noopAgent{},
config: &PodConfig{
HypervisorConfig: HypervisorConfig{
DisableBlockDeviceUse: false,
},
},
}

contID := "100"
Expand Down Expand Up @@ -258,7 +264,6 @@ func TestContainerAddDriveDir(t *testing.T) {
if container.state.Fstype == "" || !container.state.HotpluggedDrive {
t.Fatal()
}

}

func TestCheckPodRunningEmptyCmdFailure(t *testing.T) {
Expand Down Expand Up @@ -307,7 +312,10 @@ func TestContainerAddResources(t *testing.T) {
CPUQuota: 5000,
CPUPeriod: 1000,
}
c.pod = &Pod{hypervisor: &mockHypervisor{}}
c.pod = &Pod{
hypervisor: &mockHypervisor{},
agent: &noopAgent{},
}
err = c.addResources()
assert.Nil(err)
}
Expand Down

0 comments on commit 92fa5e9

Please sign in to comment.