Skip to content

Commit

Permalink
Additional UT for cli package
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajadeepan D Ramesh committed Jul 1, 2019
1 parent 3ce9a16 commit aadf906
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/cli/job/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ package job

import (
"encoding/json"
"github.com/spf13/cobra"
"net/http"
"net/http/httptest"
"testing"

v1alpha1 "volcano.sh/volcano/pkg/apis/batch/v1alpha1"
"volcano.sh/volcano/pkg/apis/batch/v1alpha1"
)

func TestDeleteJobJob(t *testing.T) {
Expand Down Expand Up @@ -63,3 +64,16 @@ func TestDeleteJobJob(t *testing.T) {
}

}

func TestInitDeleteFlags(t *testing.T) {
var cmd cobra.Command
InitDeleteFlags(&cmd)

if cmd.Flag("namespace") == nil {
t.Errorf("Could not find the flag namespace")
}
if cmd.Flag("name") == nil {
t.Errorf("Could not find the flag name")
}

}
14 changes: 14 additions & 0 deletions pkg/cli/job/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package job

import (
"encoding/json"
"github.com/spf13/cobra"
"net/http"
"net/http/httptest"
"testing"
Expand Down Expand Up @@ -62,3 +63,16 @@ func TestListJob(t *testing.T) {
}

}

func TestInitListFlags(t *testing.T) {
var cmd cobra.Command
InitListFlags(&cmd)

if cmd.Flag("namespace") == nil {
t.Errorf("Could not find the flag namespace")
}
if cmd.Flag("scheduler") == nil {
t.Errorf("Could not find the flag scheduler")
}

}
14 changes: 14 additions & 0 deletions pkg/cli/job/resume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package job

import (
"encoding/json"
"github.com/spf13/cobra"
"net/http"
"net/http/httptest"
"strings"
Expand Down Expand Up @@ -74,3 +75,16 @@ func TestResumeJob(t *testing.T) {
}

}

func TestInitResumeFlags(t *testing.T) {
var cmd cobra.Command
InitResumeFlags(&cmd)

if cmd.Flag("namespace") == nil {
t.Errorf("Could not find the flag namespace")
}
if cmd.Flag("name") == nil {
t.Errorf("Could not find the flag scheduler")
}

}
33 changes: 33 additions & 0 deletions pkg/cli/job/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package job

import (
"encoding/json"
"github.com/spf13/cobra"
"net/http"
"net/http/httptest"
"testing"
Expand All @@ -42,6 +43,7 @@ func TestCreateJob(t *testing.T) {

launchJobFlags.Master = server.URL
launchJobFlags.Namespace = "test"
launchJobFlags.Requests = "cpu=1000m,memory=100Mi"

testCases := []struct {
Name string
Expand All @@ -61,3 +63,34 @@ func TestCreateJob(t *testing.T) {
}

}

func TestInitRunFlags(t *testing.T) {
var cmd cobra.Command
InitRunFlags(&cmd)

if cmd.Flag("namespace") == nil {
t.Errorf("Could not find the flag namespace")
}
if cmd.Flag("scheduler") == nil {
t.Errorf("Could not find the flag scheduler")
}
if cmd.Flag("image") == nil {
t.Errorf("Could not find the flag image")
}
if cmd.Flag("replicas") == nil {
t.Errorf("Could not find the flag replicas")
}
if cmd.Flag("name") == nil {
t.Errorf("Could not find the flag name")
}
if cmd.Flag("min") == nil {
t.Errorf("Could not find the flag min")
}
if cmd.Flag("requests") == nil {
t.Errorf("Could not find the flag requests")
}
if cmd.Flag("limits") == nil {
t.Errorf("Could not find the flag limits")
}

}
14 changes: 14 additions & 0 deletions pkg/cli/job/suspend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package job

import (
"encoding/json"
"github.com/spf13/cobra"
"net/http"
"net/http/httptest"
"strings"
Expand Down Expand Up @@ -74,3 +75,16 @@ func TestSuspendJobJob(t *testing.T) {
}

}

func TestInitSuspendFlags(t *testing.T) {
var cmd cobra.Command
InitSuspendFlags(&cmd)

if cmd.Flag("namespace") == nil {
t.Errorf("Could not find the flag namespace")
}
if cmd.Flag("name") == nil {
t.Errorf("Could not find the flag name")
}

}
14 changes: 14 additions & 0 deletions pkg/cli/job/view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package job

import (
"encoding/json"
"github.com/spf13/cobra"
"net/http"
"net/http/httptest"
"testing"
Expand Down Expand Up @@ -63,3 +64,16 @@ func TestViewJob(t *testing.T) {
}

}

func TestInitViewFlags(t *testing.T) {
var cmd cobra.Command
InitViewFlags(&cmd)

if cmd.Flag("namespace") == nil {
t.Errorf("Could not find the flag namespace")
}
if cmd.Flag("name") == nil {
t.Errorf("Could not find the flag name")
}

}

0 comments on commit aadf906

Please sign in to comment.