column -d: Spalten löschen
This commit is contained in:
+26
-1
@@ -5,6 +5,31 @@ require 'pty'
|
||||
require_relative '../lib/rdb'
|
||||
|
||||
class SelectionTest < RdbCase
|
||||
def test_column_d_deletes_columns
|
||||
out = rdb('column', '-d', 'Cost', 'Value', file: 'inventory')
|
||||
assert_equal %w[Item Amount Description], out.lines.first.chomp.split("\t")
|
||||
assert_equal %w[1 3 rubber\ gloves], data(out).first
|
||||
assert_equal %w[Date Debit Credit], rdb('column', '-d', 'Account', 'Description', stdin: rdb('subtotal', 'Date', 'Debit', 'Credit', file: 'journal')).lines.first.chomp.split("\t")
|
||||
end
|
||||
|
||||
def test_column_d_errors
|
||||
src = File.read(File.join(@dir, 'owners'))
|
||||
[%w[-d], %w[-d Nope], %w[-d Item Owner]].each do |args|
|
||||
out, err, st = run3('column', *args, stdin: src)
|
||||
refute st.success?, "column #{args.join(' ')} should fail"
|
||||
assert_equal '', out
|
||||
refute_empty err
|
||||
end
|
||||
end
|
||||
|
||||
def test_column_d_works_on_lists_and_with_icase
|
||||
list = rdb('tabletolist', file: 'owners')
|
||||
assert_includes rdb('column', '-d', 'Item', stdin: list), "Owner\tann"
|
||||
out, _e, st = run3('column', '-d', 'COST', stdin: File.read(File.join(@dir, 'inventory')), env: { 'RDB_ICASE' => '1' })
|
||||
assert st.success?
|
||||
refute_includes out.lines.first, 'Cost'
|
||||
end
|
||||
|
||||
def test_splittable_pieces_and_errors
|
||||
out, = run3('splittable', '-4', 'inventory')
|
||||
assert_equal 4, data(File.read(File.join(@dir, 'inventoryaa'))).size
|
||||
@@ -463,7 +488,7 @@ end
|
||||
|
||||
class HelpTest < RdbCase
|
||||
def test_whatis_whatwill_commands
|
||||
assert_includes rdb('whatis', 'column'), " column - display columns of a table in any order\n column column [ Column ... ] < tableorlist\n"
|
||||
assert_includes rdb('whatis', 'column'), " column - display columns of a table in any order\n column column [ -d ] [ Column ... ] < tableorlist\n"
|
||||
assert_includes rdb('whatwill', 'total'), 'subtotal'
|
||||
assert_operator data(rdb('commands')).size, :>, 120
|
||||
assert_operator rdb('howmany').to_i, :>, 120
|
||||
|
||||
Reference in New Issue
Block a user