kontena-cli 1.1.2.rc1 → 1.1.2.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c08178a70fa7abd31742032c4a32bfcd3c448c6e
4
- data.tar.gz: d425757f104f91eef926f0cc73a212ad60fb7df1
3
+ metadata.gz: 8d73f838d7604f63336bf79e2ab6c044767e3501
4
+ data.tar.gz: f92c2116744c5dd0745292865aa95211263a2604
5
5
  SHA512:
6
- metadata.gz: b2d8888c0b79d53b134dd3b9399afbcfac958fc6e2d8ed31ea2846eaeee2f8da905ed9e70afdba11ced3bb961e50c55e586980acfca81d0796e96e0f190d1fe2
7
- data.tar.gz: 13356fee387db7005b1588a7c0a277e9f98172fbcc252d38610638a7f493cc291ad8ab3e34bcbea3c834edbf3747da5b0e27439ca4205be49230dcaed3024b41
6
+ metadata.gz: 936f1d240681d63ffe2ad4e9f10575d4f7d118dfe69e447745c16f04c56a5d2642d88298767067073e1020d370250bffb55f504c6ab54f8a45e649cba9a82546
7
+ data.tar.gz: 340f1fdb9898f45d5cd813971dadb46611afe46d624db9ad9faf8e779a269e60aeda9ecc8a10489a1de06c6e2b420b77201386b244cee4772f3ba81ddf22fd3f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2.rc1
1
+ 1.1.2.rc2
@@ -32,10 +32,13 @@ module Kontena::Cli::Stacks::YAML::Opto::Resolvers
32
32
  # @return [Integer]
33
33
  def default_index(services)
34
34
  index = services.index {|s| service_link(s) == option.default }
35
- if index
36
- index.to_i + 1
35
+
36
+ if index && !option.required?
37
+ index + 2 # extra offset for the initial <none> option
38
+ elsif index
39
+ index + 1 # menu index starts from 1
37
40
  else
38
- 0
41
+ 0 # XXX: this just explodes?
39
42
  end
40
43
  end
41
44
 
@@ -24,31 +24,54 @@ describe Kontena::Cli::Stacks::YAML::Opto::Resolvers::ServiceLink do
24
24
  end
25
25
  end
26
26
 
27
- describe '#default_index' do
27
+ context "For a required option with a default value" do
28
28
  let(:option) do
29
- ::Opto::Option.new(default: 'foo/bar')
29
+ ::Opto::Option.new(type: 'string', name: 'link', default: 'foo/bar')
30
30
  end
31
31
  let(:subject) do
32
32
  described_class.new({'prompt' => 'foo'}, option)
33
33
  end
34
34
 
35
- it 'returns matching index' do
36
- services = [
37
- {'id' => 'test/foo/foo'},
38
- {'id' => 'test/foo/bar'},
39
- {'id' => 'test/asd/asd'}
40
- ]
41
- index = subject.default_index(services)
42
- expect(index).to eq(2)
35
+ describe '#default_index' do
36
+ it 'returns matching index' do
37
+ services = [
38
+ {'id' => 'test/foo/foo'},
39
+ {'id' => 'test/foo/bar'},
40
+ {'id' => 'test/asd/asd'}
41
+ ]
42
+ index = subject.default_index(services)
43
+ expect(index).to eq(2)
44
+ end
45
+
46
+ it 'returns 0 if no matches' do
47
+ services = [
48
+ {'id' => 'test/foo/foo'},
49
+ {'id' => 'test/asd/asd'}
50
+ ]
51
+ index = subject.default_index(services)
52
+ expect(index).to eq(0)
53
+ end
54
+ end
55
+ end
56
+
57
+ context "For an optional option with a default value" do
58
+ let(:option) do
59
+ ::Opto::Option.new(type: 'string', name: 'link', default: 'foo/bar', required: false)
60
+ end
61
+ let(:subject) do
62
+ described_class.new({'prompt' => 'foo'}, option)
43
63
  end
44
64
 
45
- it 'returns 0 if no matches' do
46
- services = [
47
- {'id' => 'test/foo/foo'},
48
- {'id' => 'test/asd/asd'}
49
- ]
50
- index = subject.default_index(services)
51
- expect(index).to eq(0)
65
+ describe '#default_index' do
66
+ it 'returns matching index' do
67
+ services = [
68
+ {'id' => 'test/foo/foo'},
69
+ {'id' => 'test/foo/bar'},
70
+ {'id' => 'test/asd/asd'}
71
+ ]
72
+ index = subject.default_index(services)
73
+ expect(index).to eq(3)
74
+ end
52
75
  end
53
76
  end
54
77
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontena-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2.rc1
4
+ version: 1.1.2.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kontena, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2017-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler