-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storage-users): assimilate clean command into sessions
Signed-off-by: jkoberg <[email protected]>
- Loading branch information
Showing
2 changed files
with
219 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package command | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cs3org/reva/v2/pkg/storage" | ||
"github.com/test-go/testify/require" | ||
) | ||
|
||
func TestBuildInfo(t *testing.T) { | ||
testCases := []struct { | ||
alias string | ||
filter storage.UploadSessionFilter | ||
expectedInfo string | ||
}{ | ||
{ | ||
alias: "empty filter", | ||
filter: storage.UploadSessionFilter{}, | ||
expectedInfo: "Sessions:", | ||
}, | ||
{ | ||
alias: "processing", | ||
filter: storage.UploadSessionFilter{Processing: boolPtr(true)}, | ||
expectedInfo: "Processing sessions:", | ||
}, | ||
{ | ||
alias: "processing and not expired", | ||
filter: storage.UploadSessionFilter{Processing: boolPtr(true), Expired: boolPtr(false)}, | ||
expectedInfo: "Processing, not expired sessions:", | ||
}, | ||
{ | ||
alias: "processing and expired", | ||
filter: storage.UploadSessionFilter{Processing: boolPtr(true), Expired: boolPtr(true)}, | ||
expectedInfo: "Processing, expired sessions:", | ||
}, | ||
{ | ||
alias: "with id", | ||
filter: storage.UploadSessionFilter{ID: strPtr("123")}, | ||
expectedInfo: "Session with id '123':", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
alias := tc.alias | ||
filter := tc.filter | ||
expectedInfo := tc.expectedInfo | ||
|
||
t.Run(alias, func(t *testing.T) { | ||
require.Equal(t, expectedInfo, buildInfo(filter)) | ||
}) | ||
} | ||
} | ||
|
||
func boolPtr(b bool) *bool { | ||
return &b | ||
} | ||
|
||
func strPtr(s string) *string { | ||
return &s | ||
} |