Implement simple authkey and console tests

This commit is contained in:
Harshavardhana
2015-04-21 01:14:28 -07:00
parent 6adb5e5217
commit b42d3a3af7
2 changed files with 58 additions and 5 deletions
+11 -5
View File
@@ -16,13 +16,19 @@
package client
import . "github.com/minio-io/check"
import (
"testing"
type ClientSuite struct{}
. "github.com/minio-io/check"
)
var _ = Suite(&ClientSuite{})
func Test(t *testing.T) { TestingT(t) }
func (s *ClientSuite) TestAuthAccessKeyLength(c *C) {
type MySuite struct{}
var _ = Suite(&MySuite{})
func (s *MySuite) TestAuthAccessKeyLength(c *C) {
// short
result := IsValidSecretKey("123456789012345678901234567890123456789")
c.Assert(result, Equals, false)
@@ -36,7 +42,7 @@ func (s *ClientSuite) TestAuthAccessKeyLength(c *C) {
c.Assert(result, Equals, true)
}
func (s *ClientSuite) TestValidAccessKeyLength(c *C) {
func (s *MySuite) TestValidAccessKeyLength(c *C) {
// short
result := IsValidAccessKey("1234567890123456789")
c.Assert(result, Equals, false)
+47
View File
@@ -0,0 +1,47 @@
/*
* Mini Copy, (C) 2015 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package console
import (
"runtime"
"testing"
. "github.com/minio-io/check"
)
func Test(t *testing.T) { TestingT(t) }
type MySuite struct{}
var _ = Suite(&MySuite{})
func (s *MySuite) TestSetTheme(c *C) {
err := SetTheme("nocolor")
c.Assert(err, IsNil)
c.Assert(GetTheme(), Equals, "nocolor")
err = SetTheme("unknown")
c.Assert(err, Not(IsNil))
c.Assert(GetTheme(), Equals, "nocolor")
}
func (s *MySuite) TestDefaultTheme(c *C) {
if runtime.GOOS == "windows" {
c.Assert(GetDefaultTheme(), Equals, "nocolor")
} else {
c.Assert(GetDefaultTheme(), Equals, "minimal")
}
}