Skip to content

Commit 29c4e7b

Browse files
author
Cornelius Weig
committed
Disable completion for krew plugin builds
1 parent 4b4a3eb commit 29c4e7b

3 files changed

Lines changed: 58 additions & 28 deletions

File tree

cmd/completion.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build !getall
2+
13
/*
24
Copyright 2019 Cornelius Weig
35

cmd/completion_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// +build !getall
2+
3+
/*
4+
Copyright 2019 Cornelius Weig
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package cmd
20+
21+
import (
22+
"os"
23+
"testing"
24+
25+
"github.com/stretchr/testify/assert"
26+
27+
"github.com/corneliusweig/ketall/pkg/ketall/options"
28+
)
29+
30+
func TestMainCompletionCommand(t *testing.T) {
31+
tests := [][]string{
32+
{"ketall", "completion", "zsh"},
33+
{"ketall", "completion", "bash"},
34+
}
35+
36+
for _, testargs := range tests {
37+
t.Run(testargs[2], func(t *testing.T) {
38+
origOpts := ketallOptions
39+
newOpts, _, stdout, stderr := options.NewTestTestCmdOptions()
40+
41+
defer func(args []string) {
42+
os.Args = args
43+
ketallOptions = origOpts
44+
}(os.Args)
45+
os.Args = testargs
46+
ketallOptions = newOpts
47+
48+
err := Execute()
49+
50+
assert.NoError(t, err)
51+
assert.NotEmpty(t, stdout.String())
52+
assert.Empty(t, stderr.String())
53+
})
54+
55+
}
56+
}

cmd/root_test.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,31 +75,3 @@ func TestMainVersionCommand(t *testing.T) {
7575
assert.Contains(t, stdout.String(), "ketall:")
7676
assert.Empty(t, stderr.String())
7777
}
78-
79-
func TestMainCompletionCommand(t *testing.T) {
80-
tests := [][]string{
81-
{"ketall", "completion", "zsh"},
82-
{"ketall", "completion", "bash"},
83-
}
84-
85-
for _, testargs := range tests {
86-
t.Run(testargs[2], func(t *testing.T) {
87-
origOpts := ketallOptions
88-
newOpts, _, stdout, stderr := options.NewTestTestCmdOptions()
89-
90-
defer func(args []string) {
91-
os.Args = args
92-
ketallOptions = origOpts
93-
}(os.Args)
94-
os.Args = testargs
95-
ketallOptions = newOpts
96-
97-
err := Execute()
98-
99-
assert.NoError(t, err)
100-
assert.NotEmpty(t, stdout.String())
101-
assert.Empty(t, stderr.String())
102-
})
103-
104-
}
105-
}

0 commit comments

Comments
 (0)