github.com/uvalib/orcid-access-ws@v0.0.0-20250612130209-7d062dbabf9d/orcidaccessws/tests/search_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 // search ORCID tests 11 // 12 13 //func TestSearchOrcidHappyDay(t *testing.T) { 14 // 15 // expected := http.StatusOK 16 // status, orcids, total := client.SearchOrcid(cfg.Endpoint, goodSearch, goodSearchStart, goodSearchMax, goodToken( cfg.Secret )) 17 // if status != expected { 18 // t.Fatalf("Expected %v, got %v\n", expected, status) 19 // } 20 // 21 // ensureValidSearchResults(t, orcids, goodSearchMax, total) 22 //} 23 24 //func TestSearchOrcidMaxRows(t *testing.T) { 25 // 26 // expected := http.StatusOK 27 // status, orcids, total := client.SearchOrcid(cfg.Endpoint, goodSearch, goodSearchStart, goodSearchMax, goodToken( cfg.Secret )) 28 // if status != expected { 29 // t.Fatalf("Expected %v, got %v\n", expected, status) 30 // } 31 // 32 // ensureValidSearchResults(t, orcids, goodSearchMax, total) 33 //} 34 35 func TestSearchOrcidBadStart(t *testing.T) { 36 expected := http.StatusBadRequest 37 status, _, _ := client.SearchOrcid(cfg.Endpoint, goodSearch, badSearchStart, goodSearchMax, empty) 38 if status != expected { 39 t.Fatalf("Expected %v, got %v\n", expected, status) 40 } 41 } 42 43 func TestSearchOrcidBadMax(t *testing.T) { 44 expected := http.StatusBadRequest 45 status, _, _ := client.SearchOrcid(cfg.Endpoint, goodSearch, goodSearchStart, badSearchMax, empty) 46 if status != expected { 47 t.Fatalf("Expected %v, got %v\n", expected, status) 48 } 49 } 50 51 func TestSearchOrcidEmptySearch(t *testing.T) { 52 expected := http.StatusBadRequest 53 status, _, _ := client.SearchOrcid(cfg.Endpoint, empty, goodSearchStart, goodSearchMax, goodToken(cfg.Secret)) 54 if status != expected { 55 t.Fatalf("Expected %v, got %v\n", expected, status) 56 } 57 } 58 59 //func TestSearchOrcidNotFoundSearch(t *testing.T) { 60 // expected := http.StatusNotFound 61 // status, _, _ := client.SearchOrcid(cfg.Endpoint, notFoundSearch, goodSearchStart, goodSearchMax, goodToken( cfg.Secret )) 62 // if status != expected { 63 // t.Fatalf("Expected %v, got %v\n", expected, status) 64 // } 65 //} 66 67 func TestSearchOrcidEmptyToken(t *testing.T) { 68 expected := http.StatusBadRequest 69 status, _, _ := client.SearchOrcid(cfg.Endpoint, goodSearch, goodSearchStart, goodSearchMax, empty) 70 if status != expected { 71 t.Fatalf("Expected %v, got %v\n", expected, status) 72 } 73 } 74 75 func TestSearchOrcidBadToken(t *testing.T) { 76 expected := http.StatusForbidden 77 status, _, _ := client.SearchOrcid(cfg.Endpoint, goodSearch, goodSearchStart, goodSearchMax, badToken(cfg.Secret)) 78 if status != expected { 79 t.Fatalf("Expected %v, got %v\n", expected, status) 80 } 81 } 82 83 // 84 // end of file 85 //