File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,30 @@ BeforeAll {
66 $script :TemplateDir = Join-Path $script :RepoRoot ' config/network/tailscale/derp'
77}
88
9+ function script :Convert-ToLfLineEndings {
10+ <#
11+ . SYNOPSIS
12+ 把文本统一为 LF 行尾。
13+
14+ . DESCRIPTION
15+ GitHub Actions 在不同平台 checkout 后,原始文本断言可能拿到 LF 或 CRLF。
16+ 这里先把行尾归一化,避免 `(?m)^...$` 这类精确行匹配被 `\r` 干扰。
17+
18+ . PARAMETER Content
19+ 待归一化的原始文本。
20+
21+ . OUTPUTS
22+ System.String
23+ 返回仅使用 LF 的文本。
24+ #>
25+ param (
26+ [AllowEmptyString ()]
27+ [string ]$Content
28+ )
29+
30+ return $Content -replace " `r`n ?" , " `n "
31+ }
32+
933function script :Get-ComposeServiceBlock {
1034 <#
1135 . SYNOPSIS
@@ -68,8 +92,17 @@ Describe 'Tailscale DERP template files' {
6892}
6993
7094Describe ' Tailscale DERP Dockerfile' {
95+ It ' matches the builder stage header even if the file text uses CRLF line endings' {
96+ $dockerfile = @'
97+ ARG GO_BUILD_IMAGE=golang:1.26-alpine
98+ FROM ${GO_BUILD_IMAGE} AS build
99+ '@ -replace " `n " , " `r`n "
100+
101+ (Convert-ToLfLineEndings - Content $dockerfile ) | Should -Match ' (?m)^FROM \$\{GO_BUILD_IMAGE\} AS build$'
102+ }
103+
71104 It ' uses a Go 1.26+ builder image that can be overridden via build args' {
72- $dockerfile = Get-Content - LiteralPath (Join-Path $script :TemplateDir ' Dockerfile.derper' ) - Raw
105+ $dockerfile = Convert-ToLfLineEndings - Content ( Get-Content - LiteralPath (Join-Path $script :TemplateDir ' Dockerfile.derper' ) - Raw)
73106
74107 $dockerfile | Should -Match ' (?m)^ARG GO_BUILD_IMAGE=golang:1\.26'
75108 $dockerfile | Should -Match ' (?m)^FROM \$\{GO_BUILD_IMAGE\} AS build$'
You can’t perform that action at this time.
0 commit comments