@@ -2,68 +2,47 @@ package huggingface
22
33import (
44 "testing"
5-
5+
66 "github.com/1Password/shell-plugins/sdk"
77 "github.com/1Password/shell-plugins/sdk/plugintest"
88 "github.com/1Password/shell-plugins/sdk/schema/fieldname"
99)
10-
11- func TestAPITokenProvisioner (t * testing.T ) {
12- plugintest .TestProvisioner (t , UserAccessToken ().DefaultProvisioner , map [string ]plugintest.ProvisionCase {
13- "default" : {
14- ItemFields : map [sdk.FieldName ]string {
15- fieldname .UserAccessToken : "hf_yVvZeburdKtnwkVCWPXimmNwaFuEXAMPLE" ,
16- fieldname .Endpoint : "https://huggingface.co" ,
17- fieldname .APIUrl : "https://api-inference.huggingface.com" ,
18- },
19- ExpectedOutput : sdk.ProvisionOutput {
20- Environment : map [string ]string {
21- "HUGGINGFACE_TOKEN" : "hf_yVvZeburdKtnwkVCWPXimmNwaFuEXAMPLE" ,
22- "HF_ENDPOINT" : "https://huggingface.co" ,
23- "HF_INFERENCE_ENDPOINT" : "https://api-inference.huggingface.com" ,
2410
11+ func TestAPITokenProvisioner (t * testing.T ) {
12+ plugintest .TestProvisioner (
13+ t , UserAccessToken ().DefaultProvisioner , map [string ]plugintest.ProvisionCase {
14+ "default" : {
15+ ItemFields : map [sdk.FieldName ]string {
16+ fieldname .UserAccessToken : "hf_yVvZeburdKtnwkVCWPXimmNwaFuEXAMPLE" ,
17+ fieldname .Endpoint : "https://huggingface.co" ,
18+ fieldname .APIUrl : "https://api-inference.huggingface.com" ,
19+ },
20+ ExpectedOutput : sdk.ProvisionOutput {
21+ Environment : map [string ]string {
22+ "HUGGING_FACE_HUB_TOKEN" : "hf_yVvZeburdKtnwkVCWPXimmNwaFuEXAMPLE" ,
23+ "HF_ENDPOINT" : "https://huggingface.co" ,
24+ "HF_INFERENCE_ENDPOINT" : "https://api-inference.huggingface.com" ,
25+ },
2526 },
2627 },
27- },
28- })
28+ })
2929}
3030
3131func TestAPITokenImporter (t * testing.T ) {
32- plugintest .TestImporter (t , UserAccessToken ().Importer , map [string ]plugintest.ImportCase {
33- "environment" : {
34- Environment : map [string ]string {
35- "HUGGINGFACE_TOKEN" : "hf_yVvZeburdKtnwkVCWPXimmNwaFuEXAMPLE" ,
36- "HF_ENDPOINT" : "https://huggingface.co" ,
37- "HF_INFERENCE_ENDPOINT" : "https://api-inference.huggingface.com" ,
38- },
39- ExpectedCandidates : []sdk.ImportCandidate {
40- {
41- Fields : map [sdk.FieldName ]string {
42- fieldname .UserAccessToken : "hf_yVvZeburdKtnwkVCWPXimmNwaFuEXAMPLE" ,
43- fieldname .Endpoint : "https://huggingface.co" ,
44- fieldname .APIUrl : "https://api-inference.huggingface.com" ,
45- },
46- },
47- },
48- },
49- "token file" : {
50- Files : map [string ]string {
51- "~/.cache/huggingface/token" : plugintest .LoadFixture (t , "token" ),
52- },
53- ExpectedCandidates : []sdk.ImportCandidate {
54- {
55- 56- Fields : map [sdk.FieldName ]string {
57- fieldname .UserAccessToken : "hf_yVvZeburdKtnwkVCWPXimmNwaFuEXAMPLE" ,
58- },
32+ plugintest .TestImporter (
33+ t , UserAccessToken ().Importer , map [string ]plugintest.ImportCase {
34+ "config file (macOS)" : {
35+ Files : map [string ]string {
36+ "~/.cache/huggingface/token" : plugintest .LoadFixture (t , "token" ),
5937 },
60- {
61- 62- Fields : map [sdk.FieldName ]string {
63- fieldname .UserAccessToken : "hf_yVvZeburdKtnwkVCWPXimmNwaFuEXAMPLE" ,
38+ ExpectedCandidates : []sdk.ImportCandidate {
39+ {
40+ Fields : map [sdk.FieldName ]string {
41+ fieldname .UserAccessToken : "hf_yVvZeburdKtnwkVCWPXimmNwaFuEXAMPLE" ,
42+ },
6443 },
6544 },
6645 },
6746 },
68- } )
47+ )
6948}
0 commit comments