Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ jobs:

# run unit tests
unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm]
runs-on: ${{ matrix.os }}
permissions:
contents: read
steps:
Expand All @@ -66,7 +69,7 @@ jobs:
go-version: ${{ env.GO_VERSION }}

- name: Run unit tests
run: go test -run '' builder/installer
run: go test -v builder/...

# Build Job
build:
Expand Down
12 changes: 9 additions & 3 deletions features/src/instant-client/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import (
// Configuration
//////////

const (
defaultDownloadUrl = "https://download.oracle.com"
defaultVersionsUrlAMD64 = "https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html"
defaultVersionsUrlArm64 = "https://www.oracle.com/database/technologies/instant-client/linux-arm-aarch64-downloads.html"
)

var versionRegexp *regexp.Regexp = regexp.MustCompile(`^(\d+).(\d+).(\d+).(\d+).(\d+)$`)
var indexLineRegexp *regexp.Regexp = regexp.MustCompile(`<a[^>]*href=['"]([^'"]*download\.oracle\.com[^'"]*instantclient-basic-[^'"]*-(\d+(?:\.\d+){4})\w*\.zip)['"]`)

Expand Down Expand Up @@ -44,15 +50,15 @@ func runMain() error {
}

defaultVersionsUrl, err := installer.Tools.System.MapArchitecture(map[string]string{
installer.AMD64: "https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html",
installer.ARM64: "https://www.oracle.com/database/technologies/instant-client/linux-arm-aarch64-downloads.html",
installer.AMD64: defaultVersionsUrlAMD64,
installer.ARM64: defaultVersionsUrlArm64,
})
if err != nil {
return err
}

installer.HandleOverride(versionsUrl, defaultVersionsUrl, "instant-client-versions-url")
installer.HandleOverride(downloadUrl, "https://download.oracle.com", "instant-client-download-url")
installer.HandleOverride(downloadUrl, defaultDownloadUrl, "instant-client-download-url")

// Create and process the feature
feature := installer.NewFeature("Oracle Instant Client", false,
Expand Down
48 changes: 48 additions & 0 deletions features/src/instant-client/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package main

import (
"builder/installer"
"net/http"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func newTestInstantClientComponent() (*instantClientComponent, error) {
versionsUrl, err := installer.Tools.System.MapArchitecture(map[string]string{
installer.AMD64: defaultVersionsUrlAMD64,
installer.ARM64: defaultVersionsUrlArm64,
})
if err != nil {
return nil, err
}

return &instantClientComponent{
ComponentBase: installer.NewComponentBase("Basic Package", "latest"),
versionsUrl: versionsUrl,
downloadUrl: defaultDownloadUrl,
}, nil
}

func TestDownloadURLForAllMainVersions(t *testing.T) {
c, err := newTestInstantClientComponent()
assert.NoError(t, err)

versions, err := c.GetAllVersions()
assert.NoError(t, err)
assert.NotEmpty(t, versions)

for _, version := range versions {
t.Run(version.String(), func(t *testing.T) {
url, err := c.createDownloadURLForVersion(version)
require.NoError(t, err)

resp, err := http.Head(url)
require.NoError(t, err)
defer resp.Body.Close()

assert.Equal(t, http.StatusOK, resp.StatusCode, "expected HTTP 200 for %s", url)
})
}
}