Implement cat tests
This commit is contained in:
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Minio Client (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 main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
. "github.com/minio/check"
|
||||
)
|
||||
|
||||
func (s *CmdTestSuite) TestCatCmd(c *C) {
|
||||
configDir, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(configDir)
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
mcConfigWindowsDir = configDir
|
||||
default:
|
||||
mcConfigDir = configDir
|
||||
}
|
||||
_, err = doConfig("generate", nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
/// filesystem
|
||||
root, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(root)
|
||||
|
||||
objectPath := filepath.Join(root, "object1")
|
||||
data := "hello"
|
||||
dataLen := len(data)
|
||||
err = putTarget(objectPath, &hostConfig{}, uint64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
sourceConfigMap := make(map[string]*hostConfig)
|
||||
sourceConfigMap[objectPath] = &hostConfig{}
|
||||
|
||||
_, err = doCatCmd(sourceConfigMap, false)
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
+4
-4
@@ -84,7 +84,7 @@ func doDiffInRoutine(firstURL, secondURL string, recursive bool, ch chan diff) {
|
||||
_, firstContent, err := url2Stat(firstURL)
|
||||
if err != nil {
|
||||
ch <- diff{
|
||||
message: "Failed to stat " + firstURL + ". Reason: [" + iodine.ToError(err).Error() + "]",
|
||||
message: "Failed to stat ‘" + firstURL + "’. Reason: [" + iodine.ToError(err).Error() + "]",
|
||||
err: iodine.New(err, nil),
|
||||
}
|
||||
return
|
||||
@@ -92,7 +92,7 @@ func doDiffInRoutine(firstURL, secondURL string, recursive bool, ch chan diff) {
|
||||
_, secondContent, err := url2Stat(secondURL)
|
||||
if err != nil {
|
||||
ch <- diff{
|
||||
message: "Failed to stat " + secondURL + ". Reason: [" + iodine.ToError(err).Error() + "]",
|
||||
message: "Failed to stat ‘" + secondURL + "’. Reason: [" + iodine.ToError(err).Error() + "]",
|
||||
err: iodine.New(err, nil),
|
||||
}
|
||||
return
|
||||
@@ -112,7 +112,7 @@ func doDiffInRoutine(firstURL, secondURL string, recursive bool, ch chan diff) {
|
||||
doDiffObjects(firstURL, newSecondURL, ch)
|
||||
case !secondContent.Type.IsRegular():
|
||||
ch <- diff{
|
||||
message: firstURL + " and " + secondURL + " differs in type.",
|
||||
message: "‘" + firstURL + "’ and " + "‘" + secondURL + "’ differs in type.",
|
||||
err: nil,
|
||||
}
|
||||
return
|
||||
@@ -124,7 +124,7 @@ func doDiffInRoutine(firstURL, secondURL string, recursive bool, ch chan diff) {
|
||||
switch {
|
||||
case !secondContent.Type.IsDir():
|
||||
ch <- diff{
|
||||
message: firstURL + " and " + secondURL + " differs in type.",
|
||||
message: "‘" + firstURL + "’ and " + "‘" + secondURL + "’ differs in type.",
|
||||
err: nil,
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user