[ARVADOS] updated: 9b83c3ee103d121e9406fa93e6e95ad303dee577
Git user
git at public.curoverse.com
Mon Oct 30 22:18:44 EDT 2017
Summary of changes:
tools/arv-sync-groups/arv-sync-groups.go | 9 ++++++++-
tools/arv-sync-groups/arv-sync-groups_test.go | 27 +++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 1 deletion(-)
via 9b83c3ee103d121e9406fa93e6e95ad303dee577 (commit)
from eb772d62ecc9d1ad61df7bbf08a572fda689c5be (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 9b83c3ee103d121e9406fa93e6e95ad303dee577
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date: Mon Oct 30 23:17:42 2017 -0300
12018: Enhanced readability of ProcessFile() function.
Added test using usernames instead of emails.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>
diff --git a/tools/arv-sync-groups/arv-sync-groups.go b/tools/arv-sync-groups/arv-sync-groups.go
index 40c6934..c853cd3 100644
--- a/tools/arv-sync-groups/arv-sync-groups.go
+++ b/tools/arv-sync-groups/arv-sync-groups.go
@@ -335,7 +335,14 @@ func doMain(cfg *ConfigParams) error {
}
// ProcessFile reads the CSV file and process every record
-func ProcessFile(cfg *ConfigParams, f *os.File, userIDToUUID map[string]string, groupNameToUUID map[string]string, remoteGroups map[string]*GroupInfo, allUsers map[string]arvados.User) (groupsCreated, membersAdded, membersSkipped int, err error) {
+func ProcessFile(
+ cfg *ConfigParams,
+ f *os.File,
+ userIDToUUID map[string]string,
+ groupNameToUUID map[string]string,
+ remoteGroups map[string]*GroupInfo,
+ allUsers map[string]arvados.User,
+) (groupsCreated, membersAdded, membersSkipped int, err error) {
lineNo := 0
csvReader := csv.NewReader(f)
for {
diff --git a/tools/arv-sync-groups/arv-sync-groups_test.go b/tools/arv-sync-groups/arv-sync-groups_test.go
index e41ad88..81ae0be 100644
--- a/tools/arv-sync-groups/arv-sync-groups_test.go
+++ b/tools/arv-sync-groups/arv-sync-groups_test.go
@@ -427,3 +427,30 @@ func (s *TestSuite) TestIgnoreEmptyFields(c *C) {
c.Assert(groupUUID, Not(Equals), "")
c.Assert(GroupMembershipExists(s.cfg.Client, activeUserUUID, groupUUID), Equals, true)
}
+
+// Instead of emails, use username as identifier
+func (s *TestSuite) TestUseUsernames(c *C) {
+ activeUserName := s.users[arvadostest.ActiveUserUUID].Username
+ activeUserUUID := s.users[arvadostest.ActiveUserUUID].UUID
+ // Confirm that group doesn't exist
+ groupUUID, err := RemoteGroupExists(s.cfg, "TestGroup1")
+ c.Assert(err, IsNil)
+ c.Assert(groupUUID, Equals, "")
+ // Create file & run command
+ data := [][]string{
+ {"TestGroup1", activeUserName},
+ }
+ tmpfile, err := MakeTempCSVFile(data)
+ c.Assert(err, IsNil)
+ defer os.Remove(tmpfile.Name()) // clean up
+ s.cfg.Path = tmpfile.Name()
+ s.cfg.UserID = "username"
+ err = doMain(s.cfg)
+ s.cfg.UserID = "email"
+ c.Assert(err, IsNil)
+ // Confirm that memberships exist
+ groupUUID, err = RemoteGroupExists(s.cfg, "TestGroup1")
+ c.Assert(err, IsNil)
+ c.Assert(groupUUID, Not(Equals), "")
+ c.Assert(GroupMembershipExists(s.cfg.Client, activeUserUUID, groupUUID), Equals, true)
+}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list