]> git.giacomolli.uk - onechat/blobdiff - chatgpt_fake_helper_test.go
Order daemon and storage declarations
[onechat] / chatgpt_fake_helper_test.go
index ddd4c6736861643642d5e50a8861bcb24a13c0b1..0dca6bb7f5c67872eb0106d7f487bae7f94e058a 100644 (file)
@@ -35,6 +35,27 @@ type ChatGPTFake struct {
        access      []string
 }
 
        access      []string
 }
 
+func newChatGPTFake(t *testing.T) *ChatGPTFake {
+       t.Helper()
+
+       f := &ChatGPTFake{}
+       mux := http.NewServeMux()
+       mux.HandleFunc("POST /api/accounts/deviceauth/usercode", f.userCode)
+       mux.HandleFunc("POST /api/accounts/deviceauth/token", f.deviceToken)
+       mux.HandleFunc("POST /oauth/token", f.oauthToken)
+
+       f.Server = httptest.NewServer(mux)
+       t.Cleanup(f.Close)
+
+       return f
+}
+
+func newTestChatGPTAuth(t *testing.T, server *ChatGPTFake) *ChatGPTAuth {
+       t.Helper()
+
+       return newChatGPTAuth(filepath.Join(t.TempDir(), chatgptTokenFileName), server.URL)
+}
+
 // token returns a new access token that expires after ttl, for a token file
 // that a test writes.
 func (f *ChatGPTFake) token(ttl time.Duration) string {
 // token returns a new access token that expires after ttl, for a token file
 // that a test writes.
 func (f *ChatGPTFake) token(ttl time.Duration) string {
@@ -166,27 +187,6 @@ func (f *ChatGPTFake) oauthToken(w http.ResponseWriter, r *http.Request) {
        chatgptWriteJSON(w, answer)
 }
 
        chatgptWriteJSON(w, answer)
 }
 
-func newChatGPTFake(t *testing.T) *ChatGPTFake {
-       t.Helper()
-
-       f := &ChatGPTFake{}
-       mux := http.NewServeMux()
-       mux.HandleFunc("POST /api/accounts/deviceauth/usercode", f.userCode)
-       mux.HandleFunc("POST /api/accounts/deviceauth/token", f.deviceToken)
-       mux.HandleFunc("POST /oauth/token", f.oauthToken)
-
-       f.Server = httptest.NewServer(mux)
-       t.Cleanup(f.Close)
-
-       return f
-}
-
-func newTestChatGPTAuth(t *testing.T, server *ChatGPTFake) *ChatGPTAuth {
-       t.Helper()
-
-       return newChatGPTAuth(filepath.Join(t.TempDir(), chatgptTokenFileName), server.URL)
-}
-
 func chatgptWriteTestTokens(t *testing.T, auth *ChatGPTAuth, access, refresh string) {
        t.Helper()
 
 func chatgptWriteTestTokens(t *testing.T, auth *ChatGPTAuth, access, refresh string) {
        t.Helper()