mirror of
https://github.com/ko-build/ko.git
synced 2025-07-06 23:36:54 +02:00
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
![]() |
/*
|
||
|
Copyright 2021 Google LLC All Rights Reserved.
|
||
|
|
||
|
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 commands
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/google/ko/pkg/commands/options"
|
||
|
)
|
||
|
|
||
|
func TestOverrideDefaultBaseImageUsingBuildOption(t *testing.T) {
|
||
|
wantDigest := "sha256:76c39a6f76890f8f8b026f89e081084bc8c64167d74e6c93da7a053cb4ccb5dd"
|
||
|
wantImage := "gcr.io/distroless/static-debian9@" + wantDigest
|
||
|
bo := &options.BuildOptions{
|
||
|
BaseImage: wantImage,
|
||
|
}
|
||
|
|
||
|
baseFn := getBaseImage("all", bo)
|
||
|
res, err := baseFn(context.Background(), "ko://example.com/helloworld")
|
||
|
if err != nil {
|
||
|
t.Fatalf("getBaseImage(): %v", err)
|
||
|
}
|
||
|
|
||
|
digest, err := res.Digest()
|
||
|
if err != nil {
|
||
|
t.Fatalf("res.Digest(): %v", err)
|
||
|
}
|
||
|
gotDigest := digest.String()
|
||
|
if gotDigest != wantDigest {
|
||
|
t.Errorf("got digest %s, wanted %s", gotDigest, wantDigest)
|
||
|
}
|
||
|
}
|