Changeset 15854 in project


Ignore:
Timestamp:
09/13/09 14:38:25 (10 years ago)
Author:
sjamaan
Message:

Convert user info to an alist

Location:
release/4/estraier-client
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/estraier-client/estraier-client.scm

    r15853 r15854  
    105105      (word-count . ,(string->number (fourth info)))
    106106      (size . ,(string->number (fifth info))))))
     107
     108(define (line->user-info line)
     109  (let ((info (string-split line "\t" #t)))
     110    (map cons '(name password flags fullname misc) info)))
    107111
    108112;; Flatten all whitespace types to one regular whitespace.  Draft syntax
     
    394398        (master-uri base-uri "userlist")
    395399        #f
    396         (lambda (in)
    397           (let loop ((line (read-line in))
    398                      (lines (list)))
    399             (if (eof-object? line)
    400                 (reverse! lines)
    401                 (loop (read-line in)
    402                       (cons (string-split line "\t" #t) lines)))))))
     400        (lambda (in) (map line->user-info (read-lines in)))))
    403401
    404402(define (add-user base-uri username password
    405                   #!key flags fullname description)
     403                  #!key flags fullname misc)
    406404  (exec 'add-user
    407405        (make-request uri: (master-uri base-uri "useradd")
    408406                      method: 'POST major: 1 minor: 0)
    409407        `((name . ,username) (passwd . ,password)
    410           (flags . ,flags) (fname . ,fullname) (misc . ,description))
     408          (flags . ,flags) (fname . ,fullname) (misc . ,misc))
    411409        discard-output))
    412410
  • release/4/estraier-client/tests/run.scm

    r15853 r15854  
    3333  (let ((users (begin (add-user base-uri "testuser" "password"
    3434                                fullname: "Joe testuser"
    35                                 description: "This is just a test")
     35                                misc: "This is just a test")
    3636                      (list-users base-uri))))
    3737    (test "After adding a user, it shows up"
    3838          '("admin" "testuser")
    39           (map car users)))
     39          (map (lambda (u) (alist-ref 'name u)) users)))
    4040  (test "After deleting a user, it is gone"
    4141        '("admin")
    4242        (begin (delete-user base-uri "testuser")
    43                (map car (list-users base-uri)))))
     43               (map (lambda (u) (alist-ref 'name u)) (list-users base-uri)))))
    4444
    4545;; TODO: more in-depth tests of master result values
Note: See TracChangeset for help on using the changeset viewer.