Project

General

Profile

Download (980 Bytes) Statistics
| Branch: | Tag: | Revision:

hammer-cli-csv / test / users_test.rb @ bf81b9cf

1
require File.join(File.dirname(__FILE__), 'csv_test_helper')
2
#require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
3
require 'stringio'
4
require 'tempfile'
5

    
6
describe HammerCLICsv::UsersCommand do
7

    
8
  extend CommandTestHelper
9

    
10
  before :each do
11
  end
12

    
13
  context 'UsersCommand' do
14

    
15
    let(:cmd) { HammerCLICsv::UsersCommand.new("", ctx) }
16
    let(:options) {%w{-v -u admin -p changeme --server https://localhost:3000} }
17

    
18
    context "import" do
19
      it "imports" do
20
        file = Tempfile.new('users_test')
21
        file.write(
22
<<-eos
23
Name,Count,First Name,Last Name,Email,Organizations,Locations,Roles
24
damon.dials@megacorp.com,1,Damon,Dials,damon.dials@megacorp.com,Mega Corporation,,damondials
25
eos
26
                   )
27
        file.rewind
28

    
29
        proc {
30
          cmd.run(options + ['--csv-file', file.path]).must_equal HammerCLI::EX_OK
31
        }.must_output <<-eos
32
Updating user 'damon.dials@megacorp.com'... done
33
eos
34
        file.unlink
35
      end
36
    end
37

    
38
  end
39
end