1// Copyright 2019 CUE Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package cmd
16
17import "testing"
18
19func TestHelp(t *testing.T) {
20	cmd, err := New([]string{"help"})
21	if err != nil || cmd == nil {
22		t.Error("help command failed unexpectedly")
23	}
24
25	cmd, err = New([]string{"--help"})
26	if err != nil || cmd == nil {
27		t.Error("help command failed unexpectedly")
28	}
29
30	cmd, err = New([]string{"-h"})
31	if err != nil || cmd == nil {
32		t.Error("help command failed unexpectedly")
33	}
34
35	cmd, err = New([]string{"help", "cmd"})
36	if err != nil || cmd == nil {
37		t.Error("help command failed unexpectedly")
38	}
39
40	cmd, err = New([]string{"cmd", "--help"})
41	if err != nil || cmd == nil {
42		t.Error("help command failed unexpectedly")
43	}
44
45	cmd, err = New([]string{"cmd", "-h"})
46	if err != nil || cmd == nil {
47		t.Error("help command failed unexpectedly")
48	}
49
50	cmd, err = New([]string{"help", "eval"})
51	if err != nil || cmd == nil {
52		t.Error("help command failed unexpectedly")
53	}
54
55	cmd, err = New([]string{"eval", "--help"})
56	if err != nil || cmd == nil {
57		t.Error("help command failed unexpectedly")
58	}
59}
60