WIP switching to stubBinaryExtension
This commit is contained in:
parent
541ed3ba6f
commit
392460b81e
1 changed files with 23 additions and 45 deletions
|
|
@ -67,7 +67,9 @@ func TestManager_List(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestManager_List_Binary(t *testing.T) {
|
||||
//tempDir := t.TempDir()
|
||||
// TODO
|
||||
|
||||
}
|
||||
|
||||
func TestManager_Dispatch(t *testing.T) {
|
||||
|
|
@ -206,50 +208,19 @@ func TestManager_Upgrade_NoExtensions(t *testing.T) {
|
|||
func TestManager_Upgrade_BinaryExtension(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
|
||||
installReg := httpmock.Registry{}
|
||||
defer installReg.Verify(t)
|
||||
installClient := http.Client{Transport: &installReg}
|
||||
|
||||
io, _, _, _ := iostreams.Test()
|
||||
m := newTestManager(tempDir, &installClient, io)
|
||||
repo := ghrepo.NewWithHost("owner", "gh-bin-ext", "example.com")
|
||||
reg := httpmock.Registry{}
|
||||
defer reg.Verify(t)
|
||||
client := http.Client{Transport: ®}
|
||||
stubBinaryExtension(filepath.Join(tempDir, "extensions", "gh-bin-ext"), binManifest{
|
||||
Owner: "owner",
|
||||
Name: "gh-bin-ext",
|
||||
Host: "example.com",
|
||||
Tag: "v1.0.1",
|
||||
})
|
||||
|
||||
installReg.Register(
|
||||
httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"),
|
||||
httpmock.JSONResponse(
|
||||
release{
|
||||
Assets: []releaseAsset{
|
||||
{
|
||||
Name: "gh-bin-ext-windows-amd64",
|
||||
APIURL: "https://example.com/release/cool",
|
||||
},
|
||||
},
|
||||
}))
|
||||
installReg.Register(
|
||||
httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"),
|
||||
httpmock.JSONResponse(
|
||||
release{
|
||||
Tag: "v1.0.1",
|
||||
Assets: []releaseAsset{
|
||||
{
|
||||
Name: "gh-bin-ext-windows-amd64",
|
||||
APIURL: "https://example.com/release/cool",
|
||||
},
|
||||
},
|
||||
}))
|
||||
installReg.Register(
|
||||
httpmock.REST("GET", "release/cool"),
|
||||
httpmock.StringResponse("FAKE BINARY"))
|
||||
|
||||
err := m.Install(repo)
|
||||
assert.NoError(t, err)
|
||||
|
||||
upgradeReg := httpmock.Registry{}
|
||||
defer upgradeReg.Verify(t)
|
||||
upgradeClient := http.Client{Transport: &upgradeReg}
|
||||
|
||||
um := newTestManager(tempDir, &upgradeClient, io)
|
||||
upgradeReg.Register(
|
||||
m := newTestManager(tempDir, &client, io)
|
||||
reg.Register(
|
||||
httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"),
|
||||
httpmock.JSONResponse(
|
||||
release{
|
||||
|
|
@ -261,7 +232,7 @@ func TestManager_Upgrade_BinaryExtension(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}))
|
||||
upgradeReg.Register(
|
||||
reg.Register(
|
||||
httpmock.REST("GET", "api/v3/repos/owner/gh-bin-ext/releases/latest"),
|
||||
httpmock.JSONResponse(
|
||||
release{
|
||||
|
|
@ -273,11 +244,11 @@ func TestManager_Upgrade_BinaryExtension(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}))
|
||||
upgradeReg.Register(
|
||||
reg.Register(
|
||||
httpmock.REST("GET", "release/cool2"),
|
||||
httpmock.StringResponse("FAKE UPGRADED BINARY"))
|
||||
|
||||
err = um.Upgrade("bin-ext", false)
|
||||
err := m.Upgrade("bin-ext", false)
|
||||
assert.NoError(t, err)
|
||||
|
||||
manifest, err := os.ReadFile(filepath.Join(tempDir, "extensions/gh-bin-ext", manifestName))
|
||||
|
|
@ -500,3 +471,10 @@ func stubLocalExtension(tempDir, path string) error {
|
|||
}
|
||||
return f.Close()
|
||||
}
|
||||
|
||||
func stubBinaryExtension(path string, bm binManifest) error {
|
||||
// TODO make directory
|
||||
// TODO write manifest file
|
||||
// TODO write fake binary file
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue