mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-01 14:05:39 +00:00
71029cea2d
This updates all source files to use a new standard header for copyright and license declaration. Notably, copyright no longer includes a date, and we now use the standard SPDX-License-Identifier header. This commit was done almost entirely mechanically with perl, and then some minimal manual fixes. Updates #6865 Signed-off-by: Will Norris <will@tailscale.com>
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package version_test
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"testing"
|
|
|
|
ts "tailscale.com"
|
|
)
|
|
|
|
func TestAlpineTag(t *testing.T) {
|
|
if tag := readAlpineTag(t, "../Dockerfile.base"); tag == "" {
|
|
t.Fatal(`"FROM alpine:" not found in Dockerfile.base`)
|
|
} else if tag != ts.AlpineDockerTag {
|
|
t.Errorf("alpine version mismatch: Dockerfile.base has %q; ALPINE.txt has %q", tag, ts.AlpineDockerTag)
|
|
}
|
|
if tag := readAlpineTag(t, "../Dockerfile"); tag == "" {
|
|
t.Fatal(`"FROM alpine:" not found in Dockerfile`)
|
|
} else if tag != ts.AlpineDockerTag {
|
|
t.Errorf("alpine version mismatch: Dockerfile has %q; ALPINE.txt has %q", tag, ts.AlpineDockerTag)
|
|
}
|
|
}
|
|
|
|
func readAlpineTag(t *testing.T, file string) string {
|
|
f, err := os.ReadFile(file)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, line := range bytes.Split(f, []byte{'\n'}) {
|
|
line = bytes.TrimSpace(line)
|
|
_, suf, ok := bytes.Cut(line, []byte("FROM alpine:"))
|
|
if !ok {
|
|
continue
|
|
}
|
|
return string(suf)
|
|
}
|
|
return ""
|
|
}
|