@@ -3,33 +3,33 @@ package main
33import (
44 "testing"
55
6- "github.com/alicoding/mill/internal/domain/connector "
6+ "github.com/alicoding/mill/internal/domain/httprequest "
77)
88
9- // docs/SPEC.md §4's Update: seeded example connectors , verified at the
10- // service layer -- internal/domain/connector /builtin_test.go already
9+ // docs/SPEC.md §4's Update: seeded example requests , verified at the
10+ // service layer -- internal/domain/httprequest /builtin_test.go already
1111// proves BuiltIn()'s own data is well-formed; these tests prove
1212// ConfigureService actually seeds it (and its demo secrets) on a
1313// genuinely fresh install, and that seeding is lazy/one-shot, same
1414// pattern already proven for Workflows.
1515
16- func TestConfigureService_FreshInstall_SeedsBuiltInConnectors (t * testing.T ) {
16+ func TestConfigureService_FreshInstall_SeedsBuiltInRequests (t * testing.T ) {
1717 store := newFakeStore ()
1818 comp := NewCompositionService (store )
1919 cfg := NewConfigureService (store , comp )
2020
21- got := cfg .Connectors ()
22- want := connector .BuiltIn ()
21+ got := cfg .HTTPRequests ()
22+ want := httprequest .BuiltIn ()
2323 if len (got ) != len (want ) {
24- t .Fatalf ("Connectors () on a fresh install = %d entries, want %d (connector .BuiltIn())" , len (got ), len (want ))
24+ t .Fatalf ("HTTPRequests () on a fresh install = %d entries, want %d (httprequest .BuiltIn())" , len (got ), len (want ))
2525 }
2626 seen := map [string ]bool {}
27- for _ , c := range got {
28- seen [c .ID ] = true
27+ for _ , r := range got {
28+ seen [r .ID ] = true
2929 }
30- for _ , c := range want {
31- if ! seen [c .ID ] {
32- t .Errorf ("fresh-install Connectors () missing built-in %q" , c .ID )
30+ for _ , r := range want {
31+ if ! seen [r .ID ] {
32+ t .Errorf ("fresh-install HTTPRequests () missing built-in %q" , r .ID )
3333 }
3434 }
3535}
@@ -43,9 +43,9 @@ func TestConfigureService_FreshInstall_SeedsOAuth1DemoSecret(t *testing.T) {
4343 comp := NewCompositionService (store )
4444 cfg := NewConfigureService (store , comp )
4545
46- rc , err := cfg .resolveConnector ( connector .ExampleOAuth1ID )
46+ rc , err := cfg .resolveHTTPRequest ( httprequest .ExampleOAuth1ID )
4747 if err != nil {
48- t .Fatalf ("resolveConnector (%q) returned error: %v" , connector .ExampleOAuth1ID , err )
48+ t .Fatalf ("resolveHTTPRequest (%q) returned error: %v" , httprequest .ExampleOAuth1ID , err )
4949 }
5050 if rc .Secret == "" {
5151 t .Error ("seeded OAuth1 example's resolved Secret is empty, want Postman's published test credential (encoded)" )
@@ -62,19 +62,19 @@ func TestConfigureService_FreshInstall_SeedsPlaceholderDemoSecrets(t *testing.T)
6262 cfg := NewConfigureService (store , comp )
6363
6464 for id , want := range builtInSecrets {
65- rc , err := cfg .resolveConnector (id )
65+ rc , err := cfg .resolveHTTPRequest (id )
6666 if err != nil {
67- t .Errorf ("resolveConnector (%q) returned error: %v" , id , err )
67+ t .Errorf ("resolveHTTPRequest (%q) returned error: %v" , id , err )
6868 continue
6969 }
7070 if rc .Secret != want {
71- t .Errorf ("resolveConnector (%q) Secret = %q, want %q" , id , rc .Secret , want )
71+ t .Errorf ("resolveHTTPRequest (%q) Secret = %q, want %q" , id , rc .Secret , want )
7272 }
7373 }
7474}
7575
7676// The OAuth2 example deliberately has no keychain secret seeded --
77- // resolveConnector must still succeed (AuthOAuth2 != AuthNone, but
77+ // resolveHTTPRequest must still succeed (AuthOAuth2 != AuthNone, but
7878// there's genuinely no secret to fetch since none was ever Set) rather
7979// than erroring, since a missing-but-never-set secret and a
8080// missing-but-expected one need to be distinguishable in principle --
@@ -85,79 +85,79 @@ func TestConfigureService_FreshInstall_OAuth2Example_HasNoSecretSeeded(t *testin
8585 comp := NewCompositionService (store )
8686 cfg := NewConfigureService (store , comp )
8787
88- if _ , err := cfg .resolveConnector ( connector .ExampleOAuth2ID ); err == nil {
89- t .Error ("resolveConnector for the credential-less OAuth2 example returned nil error, want an error (no secret was ever seeded for it, matching a real not-yet-configured connector )" )
88+ if _ , err := cfg .resolveHTTPRequest ( httprequest .ExampleOAuth2ID ); err == nil {
89+ t .Error ("resolveHTTPRequest for the credential-less OAuth2 example returned nil error, want an error (no secret was ever seeded for it, matching a real not-yet-configured request )" )
9090 }
9191}
9292
9393// Seeding is lazy and one-shot, same as CompositionService's own
94- // BuiltInWorkflows pattern: deleting a seeded connector , then
94+ // BuiltInWorkflows pattern: deleting a seeded request , then
9595// constructing a second ConfigureService over the same (now-persisted)
9696// store, must NOT bring it back.
9797func TestConfigureService_DeletingABuiltIn_DoesNotReturnOnRestart (t * testing.T ) {
9898 store := newFakeStore ()
9999 comp := NewCompositionService (store )
100100 cfg := NewConfigureService (store , comp )
101101
102- if err := cfg .DeleteConnector ( connector .ExampleNoneID ); err != nil {
103- t .Fatalf ("DeleteConnector (%q) returned error: %v" , connector .ExampleNoneID , err )
102+ if err := cfg .DeleteHTTPRequest ( httprequest .ExampleNoneID ); err != nil {
103+ t .Fatalf ("DeleteHTTPRequest (%q) returned error: %v" , httprequest .ExampleNoneID , err )
104104 }
105105
106106 restarted := NewConfigureService (store , comp )
107- for _ , c := range restarted .Connectors () {
108- if c .ID == connector .ExampleNoneID {
109- t .Fatalf ("deleted built-in %q reappeared after restart, want it to stay deleted" , connector .ExampleNoneID )
107+ for _ , r := range restarted .HTTPRequests () {
108+ if r .ID == httprequest .ExampleNoneID {
109+ t .Fatalf ("deleted built-in %q reappeared after restart, want it to stay deleted" , httprequest .ExampleNoneID )
110110 }
111111 }
112112 // The other six built-ins should still be there -- deleting one
113113 // persists the whole (now-mutated) list, not just that one entry's
114114 // absence.
115- if len (restarted .Connectors ()) != len (connector .BuiltIn ())- 1 {
116- t .Errorf ("Connectors () after restart = %d entries, want %d (one deleted, the rest persisted)" , len (restarted .Connectors ()), len (connector .BuiltIn ())- 1 )
115+ if len (restarted .HTTPRequests ()) != len (httprequest .BuiltIn ())- 1 {
116+ t .Errorf ("HTTPRequests () after restart = %d entries, want %d (one deleted, the rest persisted)" , len (restarted .HTTPRequests ()), len (httprequest .BuiltIn ())- 1 )
117117 }
118118}
119119
120120// Editing a seeded example carries its BuiltIn flag forward (same
121121// "purely informational" behavior CompositionService.UpdateWorkflow
122122// already established) and correctly persists the new Description.
123- func TestUpdateConnector_PreservesBuiltInFlag_AndUpdatesDescription (t * testing.T ) {
123+ func TestUpdateHTTPRequest_PreservesBuiltInFlag_AndUpdatesDescription (t * testing.T ) {
124124 store := newFakeStore ()
125125 comp := NewCompositionService (store )
126126 cfg := NewConfigureService (store , comp )
127127
128- var original connector. Connector
129- for _ , c := range cfg .Connectors () {
130- if c .ID == connector .ExampleNoneID {
131- original = c
128+ var original httprequest. HTTPRequest
129+ for _ , r := range cfg .HTTPRequests () {
130+ if r .ID == httprequest .ExampleNoneID {
131+ original = r
132132 break
133133 }
134134 }
135135 if original .ID == "" {
136- t .Fatalf ("seeded connector %q not found" , connector .ExampleNoneID )
136+ t .Fatalf ("seeded request %q not found" , httprequest .ExampleNoneID )
137137 }
138138
139- updated , err := cfg .UpdateConnector (
140- original .ID , original .Label , original .Type , original . BaseURL , original .AuthType ,
139+ updated , err := cfg .UpdateHTTPRequest (
140+ original .ID , original .Label , original .BaseURL , original .AuthType ,
141141 original .Headers , original .OpenAPISpec , original .Auth , original .JOSE , "my own notes" ,
142142 )
143143 if err != nil {
144- t .Fatalf ("UpdateConnector returned error: %v" , err )
144+ t .Fatalf ("UpdateHTTPRequest returned error: %v" , err )
145145 }
146146 if ! updated .BuiltIn {
147- t .Error ("UpdateConnector reset BuiltIn to false, want it carried forward (purely informational)" )
147+ t .Error ("UpdateHTTPRequest reset BuiltIn to false, want it carried forward (purely informational)" )
148148 }
149149 if updated .Description != "my own notes" {
150- t .Errorf ("UpdateConnector Description = %q, want %q" , updated .Description , "my own notes" )
150+ t .Errorf ("UpdateHTTPRequest Description = %q, want %q" , updated .Description , "my own notes" )
151151 }
152152}
153153
154- func TestCreateConnector_DescriptionPersists (t * testing.T ) {
154+ func TestCreateHTTPRequest_DescriptionPersists (t * testing.T ) {
155155 cfg , _ := newTestConfigureService (t )
156- conn , err := cfg .CreateConnector ("My API" , connector . TypeHTTP , "https://example.com" , connector .AuthNone , nil , "" , nil , nil , "a helpful note" )
156+ req , err := cfg .CreateHTTPRequest ("My API" , "https://example.com" , httprequest .AuthNone , nil , "" , nil , nil , "a helpful note" )
157157 if err != nil {
158- t .Fatalf ("CreateConnector returned error: %v" , err )
158+ t .Fatalf ("CreateHTTPRequest returned error: %v" , err )
159159 }
160- if conn .Description != "a helpful note" {
161- t .Errorf ("CreateConnector Description = %q, want %q" , conn .Description , "a helpful note" )
160+ if req .Description != "a helpful note" {
161+ t .Errorf ("CreateHTTPRequest Description = %q, want %q" , req .Description , "a helpful note" )
162162 }
163163}
0 commit comments