package io.freefair.gradle.plugins.github.internal;

import io.freefair.gradle.plugins.github.GithubExtension;
import org.gradle.testfixtures.ProjectBuilder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import retrofit2.Response;

import java.io.IOException;

import static org.assertj.core.api.Assertions.assertThat;

class GithubClientTest {

    private GithubClient githubClient;

    @BeforeEach
    void setUp() {
        GithubExtension githubExtension = new GithubExtension(ProjectBuilder.builder().build().getObjects());

        githubExtension.getUsername().set("larsgrefer");
        githubExtension.getToken().set("ecddce86ef95fe71ffc31dc78b2466aa0f589a3a");

        githubClient = new GithubClient(githubExtension, null);
    }

    @Test
    void getGithubService() throws IOException {
        GithubService githubService = githubClient.getGithubService();

        Response<Repo> response = githubService.getRepository("freefair/gradle-plugins").execute();

        assertThat(response.isSuccessful()).isTrue();

        Repo repo = response.body();

        assertThat(repo.getHtml_url()).contains("freefair");
    }
}

@@ -104,16 +104,45 @@
 ension;%0A
+import okhttp3.OkHttpClient;%0A
 import o
@@ -588,150 +588,8 @@
 );%0A%0A
-        githubExtension.getUsername().set(%22larsgrefer%22);%0A        githubExtension.getToken().set(%22ecddce86ef95fe71ffc31dc78b2466aa0f589a3a%22);%0A%0A
     
@@ -646,11 +646,25 @@
 n, n
-ull
+ew OkHttpClient()
 );%0A 

fix test