A missing file reports the path the user typed rather than the syscall gh happened to make. The reason text comes from the operating system, so this checks the shape and the cause instead of the whole string.
(t *testing.T)
| 258 | // happened to make. The reason text comes from the operating system, so this |
| 259 | // checks the shape and the cause instead of the whole string. |
| 260 | func TestNewAssetMissingFile(t *testing.T) { |
| 261 | t.Chdir(t.TempDir()) |
| 262 | |
| 263 | _, err := newAsset("./nope.png", "") |
| 264 | |
| 265 | require.Error(t, err) |
| 266 | assert.True(t, strings.HasPrefix(err.Error(), "./nope.png: "), "got %q", err.Error()) |
| 267 | assert.NotContains(t, err.Error(), "stat ") |
| 268 | assert.ErrorIs(t, err, fs.ErrNotExist) |
| 269 | } |
| 270 | |
| 271 | func TestAssetMarkdown(t *testing.T) { |
| 272 | tests := []struct { |