TestExtractActionVersion tests the extractActionVersion function
(t *testing.T)
| 104 | |
| 105 | // TestExtractActionVersion tests the extractActionVersion function |
| 106 | func TestExtractActionVersion(t *testing.T) { |
| 107 | tests := []struct { |
| 108 | name string |
| 109 | uses string |
| 110 | expected string |
| 111 | }{ |
| 112 | { |
| 113 | name: "action with version tag", |
| 114 | uses: "actions/checkout@v4", |
| 115 | expected: "v4", |
| 116 | }, |
| 117 | { |
| 118 | name: "action with SHA", |
| 119 | uses: "actions/setup-node@93cb6efe18208431cddfb8368fd83d5badbf9bfd", |
| 120 | expected: "93cb6efe18208431cddfb8368fd83d5badbf9bfd", |
| 121 | }, |
| 122 | { |
| 123 | name: "action with subpath and version", |
| 124 | uses: "github/codeql-action/upload-sarif@v3", |
| 125 | expected: "v3", |
| 126 | }, |
| 127 | { |
| 128 | name: "action without version", |
| 129 | uses: "actions/checkout", |
| 130 | expected: "", |
| 131 | }, |
| 132 | { |
| 133 | name: "action with branch ref", |
| 134 | uses: "actions/setup-python@main", |
| 135 | expected: "main", |
| 136 | }, |
| 137 | } |
| 138 | |
| 139 | for _, tt := range tests { |
| 140 | t.Run(tt.name, func(t *testing.T) { |
| 141 | result := extractActionVersion(tt.uses) |
| 142 | if result != tt.expected { |
| 143 | t.Errorf("extractActionVersion(%q) = %q, want %q", tt.uses, result, tt.expected) |
| 144 | } |
| 145 | }) |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | // TestApplyActionPinToStep tests the ApplyActionPinToStep function |
| 150 | func TestApplyActionPinToStep(t *testing.T) { |
nothing calls this directly
no test coverage detected