test: add test data directories (testMusic and testCharacters)
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// TestCheckLatest verifies the /download endpoint
|
||||
func TestCheckLatest(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("Skipping external API test in short mode")
|
||||
}
|
||||
|
||||
e := StartTestServer(t)
|
||||
|
||||
resp := MakeTestRequest(t, e, "GET", "/download")
|
||||
assert.Equal(t, http.StatusOK, resp.Code)
|
||||
|
||||
var version string
|
||||
err := json.Unmarshal(resp.Body.Bytes(), &version)
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, version, "Should return version string")
|
||||
t.Logf("Latest version: %s", version)
|
||||
}
|
||||
|
||||
// TestListAssetsOfLatest verifies the /download/list endpoint
|
||||
func TestListAssetsOfLatest(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("Skipping external API test in short mode")
|
||||
}
|
||||
|
||||
e := StartTestServer(t)
|
||||
|
||||
resp := MakeTestRequest(t, e, "GET", "/download/list")
|
||||
assert.Equal(t, http.StatusOK, resp.Code)
|
||||
|
||||
var assets []string
|
||||
err := json.Unmarshal(resp.Body.Bytes(), &assets)
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, assets, "Should return list of assets")
|
||||
t.Logf("Found %d assets", len(assets))
|
||||
}
|
||||
|
||||
// TestDownloadLatestWindows verifies the /download/windows endpoint
|
||||
func TestDownloadLatestWindows(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("Skipping external API test in short mode")
|
||||
}
|
||||
|
||||
e := StartTestServer(t)
|
||||
|
||||
resp := MakeTestRequest(t, e, "GET", "/download/windows")
|
||||
assert.Equal(t, http.StatusOK, resp.Code)
|
||||
|
||||
var url string
|
||||
err := json.Unmarshal(resp.Body.Bytes(), &url)
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, url, "Should return download URL")
|
||||
assert.Contains(t, url, "http", "URL should be valid")
|
||||
t.Logf("Windows download URL: %s", url)
|
||||
}
|
||||
|
||||
// TestDownloadLatestLinux verifies the /download/linux endpoint
|
||||
func TestDownloadLatestLinux(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("Skipping external API test in short mode")
|
||||
}
|
||||
|
||||
e := StartTestServer(t)
|
||||
|
||||
resp := MakeTestRequest(t, e, "GET", "/download/linux")
|
||||
assert.Equal(t, http.StatusOK, resp.Code)
|
||||
|
||||
var url string
|
||||
err := json.Unmarshal(resp.Body.Bytes(), &url)
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, url, "Should return download URL")
|
||||
assert.Contains(t, url, "http", "URL should be valid")
|
||||
t.Logf("Linux download URL: %s", url)
|
||||
}
|
||||
Reference in New Issue
Block a user