Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/integration/tests/35_list_from_ceph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ for n in {1..10}; do
rm "data_file-$n.c4gh"
done

if [ "$(./sda-cli -config testing/ceph.conf list | wc -l)" -ne 11 ]; then
if [ "$(./sda-cli -config testing/ceph.conf list | wc -l)" -ne 10 ]; then
echo "Wrong number of files returned from ceph backend"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func Download(args []string, configPath string) error {
}

// print the host_base for the user
fmt.Printf("Remote server (host_base): %s\n", config.HostBase)
helpers.PrintHostBase(config.HostBase)

switch {
// Case where the user is setting the -dataset flag
Expand Down
12 changes: 6 additions & 6 deletions download/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,21 @@ func (suite *TestSuite) TestPrintHostBase() {
log.SetOutput(&str)
defer log.SetOutput(os.Stdout)

// check if the host_base is in the output
rescueStdout := os.Stdout
// check if the host_base is in the error output
rescueStderr := os.Stderr
r, w, _ := os.Pipe()
os.Stdout = w
os.Stderr = w

_ = Download(os.Args, confPath.Name())

w.Close()
os.Stdout = rescueStdout
uploadOutput, _ := io.ReadAll(r)
os.Stderr = rescueStderr
uploadError, _ := io.ReadAll(r)

// check if the host_base is in the output

expectedHostBase := "Remote server (host_base): " + "inbox.dummy.org"
assert.Contains(suite.T(), string(uploadOutput), expectedHostBase)
assert.Contains(suite.T(), string(uploadError), expectedHostBase)
}
func (suite *TestSuite) TestGetBody() {
// Create a test server
Expand Down
4 changes: 4 additions & 0 deletions helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,7 @@ func paginateListV2(svc *s3.S3, params *s3.ListObjectsV2Input) ([]*s3.Object, er

return fullResult, nil
}

func PrintHostBase(hostBase string) {
fmt.Fprintf(os.Stderr, "Remote server (host_base): %s\n", hostBase)
}
2 changes: 1 addition & 1 deletion list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func List(args []string, configPath string) error {
}

// print the host_base for the user
fmt.Printf("Remote server (host_base): %s\n", config.HostBase)
helpers.PrintHostBase(config.HostBase)

// case datasets
if *datasets {
Expand Down
13 changes: 11 additions & 2 deletions list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ func (suite *TestSuite) TestFunctionality() {
r, w, _ := os.Pipe()
os.Stdout = w

rescueStderr := os.Stderr
errR, errW, _ := os.Pipe()
os.Stderr = errW

os.Args = []string{"list"}
err = List(os.Args, configPath.Name())
assert.NoError(suite.T(), err)
Expand All @@ -151,7 +155,12 @@ func (suite *TestSuite) TestFunctionality() {
msg1 := fmt.Sprintf("%v", filepath.Base(testfile.Name()))
assert.Contains(suite.T(), string(listOutput), msg1)

// Check if host_base is in the output
errW.Close()
os.Stderr = rescueStderr
listError, _ := io.ReadAll(errR)

// Check that host_base is in the error output, not in the stdout
expectedHostBase := "Remote server (host_base): " + strings.TrimPrefix(ts.URL, "http://")
assert.Contains(suite.T(), string(listOutput), expectedHostBase)
assert.NotContains(suite.T(), string(listOutput), expectedHostBase)
assert.Contains(suite.T(), string(listError), expectedHostBase)
}
2 changes: 1 addition & 1 deletion upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func Upload(args []string, configPath string) error {
}

// print the host_base for the user
fmt.Printf("Remote server (host_base): %s\n", config.HostBase)
helpers.PrintHostBase(config.HostBase)

// Check that input file/folder list is not empty
if len(Args.Args()) == 0 {
Expand Down
9 changes: 8 additions & 1 deletion upload/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,25 @@ func (suite *TestSuite) TestFunctionality() {
rescueStdout := os.Stdout
r, w, _ := os.Pipe()
os.Stdout = w
rescueStderr := os.Stderr
errR, errW, _ := os.Pipe()
os.Stderr = errW

os.Args = []string{"upload", "--force-unencrypted", "-r", dir}
_ = Upload(os.Args, configPath.Name())

w.Close()
errW.Close()
os.Stdout = rescueStdout
os.Stderr = rescueStderr
uploadOutput, _ := io.ReadAll(r)
uploadError, _ := io.ReadAll(errR)

// check if the host_base is in the output

expectedHostBase := "Remote server (host_base): " + strings.TrimPrefix(ts.URL, "http://")
assert.Contains(suite.T(), string(uploadOutput), expectedHostBase)
assert.NotContains(suite.T(), string(uploadOutput), expectedHostBase)
assert.Contains(suite.T(), string(uploadError), expectedHostBase)

// Check that trying to encrypt already encrypted files returns error and aborts
newArgs = []string{"upload", "--encrypt-with-key", publicKey.Name(), dir, "-r"}
Expand Down
Loading