github.com/uvalib/orcid-access-ws@v0.0.0-20250612130209-7d062dbabf9d/orcidaccessws/tests/del_attribs_test.go (about) 1 package test 2 3 import ( 4 "github.com/uvalib/orcid-access-ws/orcidaccessws/client" 5 "net/http" 6 "testing" 7 ) 8 9 // 10 // delete ORCID attributes tests 11 // 12 13 func TestDeleteOrcidAtributesHappyDay(t *testing.T) { 14 15 expected := http.StatusOK 16 17 id := randomCid() 18 attributes := randomOrcidAttributes() 19 status := client.SetOrcidAttributes(cfg.Endpoint, id, goodToken(cfg.Secret), attributes) 20 if status != expected { 21 t.Fatalf("Expected %v, got %v\n", expected, status) 22 } 23 24 status = client.DelOrcidAttributes(cfg.Endpoint, id, goodToken(cfg.Secret)) 25 if status != expected { 26 t.Fatalf("Expected %v, got %v\n", expected, status) 27 } 28 } 29 30 func TestDeleteOrcidAttributesEmptyId(t *testing.T) { 31 expected := http.StatusBadRequest 32 status := client.DelOrcidAttributes(cfg.Endpoint, empty, goodToken(cfg.Secret)) 33 if status != expected { 34 t.Fatalf("Expected %v, got %v\n", expected, status) 35 } 36 } 37 38 //func TestDeleteOrcidAttributesNotFoundId( t *testing.T ) { 39 // expected := http.StatusNotFound 40 // status := client.DelOrcidAttributes( cfg.Endpoint, badCid, goodToken( cfg.Secret ) ) 41 // if status != expected { 42 // t.Fatalf( "Expected %v, got %v\n", expected, status ) 43 // } 44 //} 45 46 func TestDeleteOrcidAttributesEmptyToken(t *testing.T) { 47 expected := http.StatusBadRequest 48 status := client.DelOrcidAttributes(cfg.Endpoint, goodCid, empty) 49 if status != expected { 50 t.Fatalf("Expected %v, got %v\n", expected, status) 51 } 52 } 53 54 func TestDeleteOrcidAttributesBadToken(t *testing.T) { 55 expected := http.StatusForbidden 56 status := client.DelOrcidAttributes(cfg.Endpoint, goodCid, badToken(cfg.Secret)) 57 if status != expected { 58 t.Fatalf("Expected %v, got %v\n", expected, status) 59 } 60 } 61 62 // 63 // end of file 64 //