Skip to content

Commit

Permalink
drop legacy test packages that were once used by test-infra
Browse files Browse the repository at this point in the history
  • Loading branch information
dprotaso committed Jun 21, 2024
1 parent 915c009 commit 0a96666
Show file tree
Hide file tree
Showing 35 changed files with 78 additions and 4,455 deletions.
44 changes: 44 additions & 0 deletions test/ci/ci.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package ci

import (
"log"
"os"
"strings"
)

const (
// ArtifactsDir is the dir containing artifacts
ArtifactsDir = "artifacts"
)

// IsCI returns whether the current environment is a CI environment.
func IsCI() bool {
return strings.EqualFold(os.Getenv("CI"), "true")
}

// GetLocalArtifactsDir gets the artifacts directory where prow looks for artifacts.
// By default, it will look at the env var ARTIFACTS.
func GetLocalArtifactsDir() string {
dir := os.Getenv("ARTIFACTS")
if dir == "" {
log.Printf("Env variable ARTIFACTS not set. Using %s instead.", ArtifactsDir)
dir = ArtifactsDir
}
return dir
}
30 changes: 18 additions & 12 deletions test/prow/env_test.go → test/ci/ci_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Knative Authors
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,25 +14,31 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package prow
package ci

import (
"testing"
)

func TestGetEnvConfig(t *testing.T) {
func TestIsCI(t *testing.T) {
t.Setenv("CI", "true")
ec, err := GetEnvConfig()
t.Log("EnvConfig is:", ec)
if err != nil {
t.Fatal("Error getting envconfig for Prow:", err)
if ic := IsCI(); !ic {
t.Fatal("Expected: true, actual: false")
}
if !ec.CI {
t.Fatal("Expected CI to be true but is false")
}

func TestGetArtifacts(t *testing.T) {
// Test we can read from the env var
t.Setenv("ARTIFACTS", "test")
v := GetLocalArtifactsDir()
if v != "test" {
t.Fatalf("Actual artifacts dir: '%s' and Expected: 'test'", v)
}

t.Setenv("CI", "false")
if _, err = GetEnvConfig(); err == nil {
t.Fatal("Expected an error if called from a non-CI environment but got nil")
// Test we can use the default
t.Setenv("ARTIFACTS", "")
v = GetLocalArtifactsDir()
if v != "artifacts" {
t.Fatalf("Actual artifacts dir: '%s' and Expected: 'artifacts'", v)
}
}
51 changes: 0 additions & 51 deletions test/gcs/client.go

This file was deleted.

Loading

0 comments on commit 0a96666

Please sign in to comment.