(t *testing.T)
| 435 | } |
| 436 | |
| 437 | func Test_getBody(t *testing.T) { |
| 438 | tests := []struct { |
| 439 | name string |
| 440 | bodyArg string |
| 441 | want string |
| 442 | stdin string |
| 443 | }{ |
| 444 | { |
| 445 | name: "literal value", |
| 446 | bodyArg: "a variable", |
| 447 | want: "a variable", |
| 448 | }, |
| 449 | { |
| 450 | name: "from stdin", |
| 451 | want: "a variable", |
| 452 | stdin: "a variable", |
| 453 | }, |
| 454 | { |
| 455 | name: "from stdin with trailing newline character", |
| 456 | want: "a variable", |
| 457 | stdin: "a variable\n", |
| 458 | }, |
| 459 | } |
| 460 | |
| 461 | for _, tt := range tests { |
| 462 | t.Run(tt.name, func(t *testing.T) { |
| 463 | ios, stdin, _, _ := iostreams.Test() |
| 464 | ios.SetStdinTTY(false) |
| 465 | _, err := stdin.WriteString(tt.stdin) |
| 466 | assert.NoError(t, err) |
| 467 | opts := &SetOptions{ |
| 468 | IO: ios, |
| 469 | Body: tt.bodyArg, |
| 470 | } |
| 471 | body, err := getBody(opts) |
| 472 | assert.NoError(t, err) |
| 473 | assert.Equal(t, tt.want, body) |
| 474 | }) |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | func Test_getVariablesFromOptions(t *testing.T) { |
| 479 | genFile := func(s string) string { |
nothing calls this directly
no test coverage detected