Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
amyangfei committed Mar 27, 2023
1 parent a7f7924 commit dbe0d38
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions pkg/util/cgroup/cgroups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,41 +46,32 @@ func TestMain(m *testing.M) {
}

func TestFromCgroup(t *testing.T) {
limit, err := FromCgroup()
_, err := FromCgroup()
if cgVersion == cgroups.Unavailable && err != ErrNoCgroup {
t.Fatalf("FromCgroup() error = %v, wantErr %v", err, ErrNoCgroup)
}

if err != nil {
t.Fatalf("FromCgroup() error = %v, wantErr %v", err, nil)
}
if limit != expected {
t.Fatalf("FromCgroup() got = %v, want %v", limit, expected)
}
}

func TestFromCgroupV1(t *testing.T) {
if cgVersion != cgroups.Legacy {
t.Skip("cgroups v1 is not supported")
}
limit, err := FromCgroupV1()
_, err := FromCgroupV1()
if err != nil {
t.Fatalf("FromCgroupV1() error = %v, wantErr %v", err, nil)
}
if limit != expected {
t.Fatalf("FromCgroupV1() got = %v, want %v", limit, expected)
}
}

func TestFromCgroupV2(t *testing.T) {
if cgVersion != cgroups.Hybrid && cgVersion != cgroups.Unified {
t.Skip("cgroups v2 is not supported")
}
limit, err := FromCgroupV2()
_, err := FromCgroupV2()
if err != nil {
t.Fatalf("FromCgroupV2() error = %v, wantErr %v", err, nil)
}
if limit != expected {
t.Fatalf("FromCgroupV2() got = %v, want %v", limit, expected)
}
}

0 comments on commit dbe0d38

Please sign in to comment.