package main

import (
	. "github.com/pingcap/check"
)

func (t *testLoaderSuite) TestConfigParse(c *C) {

	var sqlModeTests = []struct {
		args  []string
		isErr bool
	}{
		{[]string{"-m", ""}, false},
		{[]string{"-m", "NO_ENGINE_SUBSTITUTION"}, false},
		{[]string{"-m", "NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"}, false},
		{[]string{"-m", LoaderSQLModePlaceHolder}, false},
		{[]string{""}, true},
		{[]string{"-m", "invalid_sql_mode"}, true},
	}

	for _, tests := range sqlModeTests {
		cfg := NewConfig()
		err := cfg.Parse(tests.args)
		if tests.isErr {
			c.Assert(err, NotNil)
		} else {
			c.Assert(err, IsNil)
		}
	}
}
