Project

General

Profile

Download (1.8 KB) Statistics
| Branch: | Tag: | Revision:

hammer-cli-csv / test / content_views_test.rb @ 400832c6

1
require File.join(File.dirname(__FILE__), 'csv_test_helper')
2

    
3
require 'stringio'
4
require 'tempfile'
5

    
6
describe 'content-views' do
7
  extend CommandTestHelper
8

    
9
  before :each do
10
    HammerCLI::Settings.load_from_file 'test/config.yml'
11
  end
12

    
13
  context "import" do
14
    it "hammer csv content-views --verbose --file does-not-exist" do
15
      stdout,stderr = capture {
16
        hammer.run(%W{csv content-views --verbose --file does-not-exist})
17
      }
18
      stdout.must_equal ''
19
      stderr[0..-2].must_equal('Error: No such file or directory - does-not-exist')
20
    end
21

    
22
    it "hammer csv content-views --verbose --file tempfile" do
23
      contentview = "contentview#{rand(10000)}"
24
      file = Tempfile.new('content_views_test')
25
      file.write("Name,Count,Organization,Description,Composite,Repositories,Lifecycle Environments\n")
26
      file.write("#{contentview},1,Mega Corporation,Katello - The Sysadmin's Fortress,No,Default_Organization_View,Library\n")
27
      file.rewind
28

    
29
      stdout,stderr = capture {
30
        hammer.run(%W{csv content-views --verbose --file #{file.path}})
31
      }
32
      stdout[0..-2].must_equal "Creating content view '#{contentview}'...done"
33

    
34
      file.unlink
35
    end
36

    
37
    it "hammer csv content-views --verbose --file tempfile (no Count column)" do
38
      contentview = "contentview#{rand(10000)}"
39
      file = Tempfile.new('content_views_test')
40
      file.write("Name,Organization,Description,Composite,Repositories,Lifecycle Environments\n")
41
      file.write("#{contentview},Mega Corporation,Katello - The Sysadmin's Fortress,No,Default_Organization_View,Library\n")
42
      file.rewind
43

    
44
      stdout,stderr = capture {
45
        hammer.run(%W{csv content-views --verbose --file #{file.path}})
46
      }
47
      stdout[0..-2].must_equal "Creating content view '#{contentview}'...done"
48

    
49
      file.unlink
50
    end
51
  end
52
end