|
| 1 | +require 'spec_helper_acceptance' |
| 2 | + |
| 3 | +describe 'mysql_database' do |
| 4 | + describe 'setup' do |
| 5 | + it 'should work with no errors' do |
| 6 | + pp = <<-EOS |
| 7 | + class { 'mysql::server': } |
| 8 | + EOS |
| 9 | + |
| 10 | + apply_manifest(pp, :catch_failures => true) |
| 11 | + end |
| 12 | + end |
| 13 | + |
| 14 | + describe 'creating database' do |
| 15 | + it 'should work without errors' do |
| 16 | + pp = <<-EOS |
| 17 | + mysql_database { 'spec_db': |
| 18 | + ensure => present, |
| 19 | + } |
| 20 | + EOS |
| 21 | + |
| 22 | + apply_manifest(pp, :catch_failures => true) |
| 23 | + end |
| 24 | + |
| 25 | + it 'should find the database' do |
| 26 | + shell("mysql -NBe \"SHOW DATABASES LIKE 'spec_db'\"") do |r| |
| 27 | + expect(r.stdout).to match(/^spec_db$/) |
| 28 | + expect(r.stderr).to be_empty |
| 29 | + end |
| 30 | + end |
| 31 | + end |
| 32 | + |
| 33 | + describe 'charset and collate' do |
| 34 | + it 'should create two db of different types idempotently' do |
| 35 | + pp = <<-EOS |
| 36 | + mysql_database { 'spec_latin1': |
| 37 | + charset => 'latin1', |
| 38 | + collate => 'latin1_swedish_ci', |
| 39 | + } |
| 40 | + mysql_database { 'spec_utf8': |
| 41 | + charset => 'utf8', |
| 42 | + collate => 'utf8_general_ci', |
| 43 | + } |
| 44 | + EOS |
| 45 | + |
| 46 | + apply_manifest(pp, :catch_failures => true) |
| 47 | + apply_manifest(pp, :catch_changes => true) |
| 48 | + end |
| 49 | + |
| 50 | + it 'should find latin1 db' do |
| 51 | + shell("mysql -NBe \"SHOW VARIABLES LIKE '%_database'\" spec_latin1") do |r| |
| 52 | + expect(r.stdout).to match(/^character_set_database\tlatin1\ncollation_database\tlatin1_swedish_ci$/) |
| 53 | + expect(r.stderr).to be_empty |
| 54 | + end |
| 55 | + end |
| 56 | + |
| 57 | + it 'should find utf8 db' do |
| 58 | + shell("mysql -NBe \"SHOW VARIABLES LIKE '%_database'\" spec_utf8") do |r| |
| 59 | + expect(r.stdout).to match(/^character_set_database\tutf8\ncollation_database\tutf8_general_ci$/) |
| 60 | + expect(r.stderr).to be_empty |
| 61 | + end |
| 62 | + end |
| 63 | + end |
| 64 | +end |
0 commit comments