Skip to content

Commit

Permalink
Add unit tests for non-redhat and redhat distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumerose committed Nov 6, 2020
1 parent bbd0237 commit 603bdfa
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 25 deletions.
19 changes: 19 additions & 0 deletions pkg/crc/preflight/preflight_darwin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package preflight

import (
"testing"

"github.com/code-ready/crc/pkg/crc/config"
"github.com/stretchr/testify/assert"
)

func TestCountConfigurationOptions(t *testing.T) {
cfg := config.New(config.NewEmptyInMemoryStorage())
RegisterSettings(cfg)
assert.Len(t, cfg.AllConfigs(), 20)
}

func TestCountPreflights(t *testing.T) {
assert.Len(t, getPreflightChecks(false), 10)
assert.Len(t, getPreflightChecks(true), 16)
}
27 changes: 27 additions & 0 deletions pkg/crc/preflight/preflight_linux_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package preflight

import (
"testing"

"github.com/code-ready/crc/pkg/crc/config"
crcos "github.com/code-ready/crc/pkg/os/linux"
"github.com/stretchr/testify/assert"
)

func TestCountConfigurationOptions(t *testing.T) {
cfg := config.New(config.NewEmptyInMemoryStorage())
RegisterSettings(cfg)
options := len(cfg.AllConfigs())
assert.True(t, options == 40 || options == 32)
}

func TestCountPreflights(t *testing.T) {
assert.Len(t, getPreflightChecksForDistro(crcos.RHEL, false), 21)
assert.Len(t, getPreflightChecksForDistro(crcos.RHEL, true), 21)

assert.Len(t, getPreflightChecksForDistro("unexpected", false), 21)
assert.Len(t, getPreflightChecksForDistro("unexpected", true), 21)

assert.Len(t, getPreflightChecksForDistro(crcos.Ubuntu, false), 17)
assert.Len(t, getPreflightChecksForDistro(crcos.Ubuntu, true), 17)
}
25 changes: 0 additions & 25 deletions pkg/crc/preflight/preflight_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,12 @@ package preflight

import (
"errors"
"runtime"
"testing"

"github.com/code-ready/crc/pkg/crc/config"
"github.com/stretchr/testify/assert"
)

func TestCountConfigurationOptions(t *testing.T) {
cfg := config.New(config.NewEmptyInMemoryStorage())
RegisterSettings(cfg)
assert.Len(t, cfg.AllConfigs(), map[string]int{
"darwin": 20,
"linux": 40,
"windows": 24,
}[runtime.GOOS])
}

func TestCountPreflights(t *testing.T) {
assert.Len(t, getPreflightChecks(false), map[string]int{
"darwin": 10,
"linux": 21,
"windows": 14,
}[runtime.GOOS])

assert.Len(t, getPreflightChecks(true), map[string]int{
"darwin": 16,
"linux": 21,
"windows": 16,
}[runtime.GOOS])
}

func TestCheckPreflight(t *testing.T) {
check, calls := sampleCheck(nil, nil)
cfg := config.New(config.NewEmptyInMemoryStorage())
Expand Down
19 changes: 19 additions & 0 deletions pkg/crc/preflight/preflight_windows_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package preflight

import (
"testing"

"github.com/code-ready/crc/pkg/crc/config"
"github.com/stretchr/testify/assert"
)

func TestCountConfigurationOptions(t *testing.T) {
cfg := config.New(config.NewEmptyInMemoryStorage())
RegisterSettings(cfg)
assert.Len(t, cfg.AllConfigs(), 24)
}

func TestCountPreflights(t *testing.T) {
assert.Len(t, getPreflightChecks(false), 14)
assert.Len(t, getPreflightChecks(true), 16)
}
1 change: 1 addition & 0 deletions pkg/os/linux/release_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
RHEL OsType = "rhel"
Fedora OsType = "fedora"
CentOS OsType = "centos"
Ubuntu OsType = "ubuntu"
)

func stripQuotes(val string) string {
Expand Down

0 comments on commit 603bdfa

Please sign in to comment.