okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
47735ec
main
1package daemon 2 3import ( 4"encoding/json" 5"net/http" 6"testing" 7) 8 9func TestSignInListPopulatesKind (t * testing.T ) { 10conn := controlledConnection (t ,func (w http.ResponseWriter ,r * http.Request ) { 11if r .URL .Path != "/auth" { 12t .Errorf ("unexpected path: %s" ,r .URL .Path ) 13 } 14_ = json .NewEncoder (w ).Encode (map [string ]any { 15"providers" : []map [string ]any { 16 { 17"id" :"claude" , 18"label" :"Claude" , 19"detail" :"console billing" , 20"kind" :"model" , 21"flows" : []string {"browser" }, 22"fields" : []any {}, 23 }, 24 { 25"id" :"colab" , 26"label" :"Google Colab" , 27"detail" :"service account" , 28"kind" :"service" , 29"flows" : []string {"browser" }, 30"fields" : []any {}, 31 }, 32 }, 33"accounts" : []map [string ]any { 34 { 35"id" :"acc-model" , 36"provider" :"claude" , 37"label" :"user@example.com" , 38"detail" :"pro plan" , 39"kind" :"model" , 40"selected_by_profiles" : []string {"claude" }, 41 }, 42 { 43"id" :"acc-service" , 44"provider" :"colab" , 45"label" :"service@example.com" , 46"detail" :"colab tokens" , 47"kind" :"service" , 48"selected_by_profiles" : []string {}, 49 }, 50 }, 51 }) 52 }) 53 54list ,err := SignInList (t .Context (),conn ) 55if err != nil { 56t .Fatalf ("SignInList failed: %v" ,err ) 57 } 58if len (list .Logins )!= 2 || list .Logins [0 ].Kind != "model" || list .Logins [1 ].Kind != "service" { 59t .Fatalf ("unexpected logins kind: %+v" ,list .Logins ) 60 } 61if len (list .Accounts )!= 2 || list .Accounts [0 ].Kind != "model" || list .Accounts [1 ].Kind != "service" { 62t .Fatalf ("unexpected accounts kind: %+v" ,list .Accounts ) 63 } 64}