require 'test/unit'
require 'criteria/mysql'
include Criteria

class TestMySQL < Test::Unit::TestCase
  def test_mysql
    tbl = res = nil

    assert_nothing_raised {
      tbl = MysqlTable.create($DB, "foo",
                              [:id,   Integer, "int NOT NULL auto_increment"],
                              [:name, String],
                              [:age,  Integer],
                              SQLFn.pk(:id))
    }

    assert_nothing_raised {
      tbl.insert(nil, "Bob", 5)
    }
      
    assert_nothing_raised {
      tbl.insert(:name => "John Doe",
                 :age  => 32)

      tbl.insert(:name => "Jane Doe",
                 :age  => 32)
    }

    assert_nothing_raised {
      res = tbl.*.select_parse
    }

    assert_nothing_raised {
      MysqlTable.drop($DB, tbl)
    }
  end #m:test_mysql
end
