|
1 | 1 | package utils |
2 | 2 |
|
3 | | -import "testing" |
| 3 | +import ( |
| 4 | + "testing" |
4 | 5 |
|
5 | | -func TestPositiveReadinessCheck(t *testing.T) { |
6 | | - result := IsReady(` |
7 | | - -- Logs begin at Wed 2021-01-20 00:25:37 UTC, end at Fri 2021-02-26 15:37:56 UTC. -- |
8 | | - Feb 26 15:37:20 ip-172-31-6-188 cml.sh[2203]: {"level":"info","time":"···","repo":"···","status":"ready"} |
9 | | - `) |
10 | | - if !result { |
11 | | - t.Errorf("Positive readiness check") |
12 | | - } |
13 | | -} |
| 6 | + "github.com/stretchr/testify/assert" |
| 7 | +) |
| 8 | + |
| 9 | +func TestReadinessCheck(t *testing.T) { |
| 10 | + t.Run("Runner log containing a readiness message should be considered ready", func(t *testing.T) { |
| 11 | + logString := ` |
| 12 | + -- Logs begin at Wed 2021-01-20 00:25:37 UTC, end at Fri 2021-02-26 15:37:56 UTC. -- |
| 13 | + Feb 26 15:37:20 ip-172-31-6-188 cml.sh[2203]: {"level":"info","time":"···","repo":"···","status":"ready"} |
| 14 | + ` |
| 15 | + assert.True(t, IsReady(logString)) |
| 16 | + }) |
14 | 17 |
|
15 | | -func TestNegativeReadinessCheck(t *testing.T) { |
16 | | - result := IsReady(` |
17 | | - -- Logs begin at Wed 2021-01-20 00:25:37 UTC, end at Fri 2021-02-26 15:37:56 UTC. -- |
18 | | - Feb 26 15:37:20 ip-172-31-6-188 cml.sh[2203]: {"level":"info","time":"···","repo":"···"} |
19 | | - `) |
20 | | - if result { |
21 | | - t.Errorf("Negative readiness check") |
22 | | - } |
| 18 | + t.Run("Runner log not containing a readiness message should not be considered ready", func(t *testing.T) { |
| 19 | + logString := ` |
| 20 | + -- Logs begin at Wed 2021-01-20 00:25:37 UTC, end at Fri 2021-02-26 15:37:56 UTC. -- |
| 21 | + Feb 26 15:37:20 ip-172-31-6-188 cml.sh[2203]: {"level":"info","time":"···","repo":"···"} |
| 22 | + ` |
| 23 | + assert.False(t, IsReady(logString)) |
| 24 | + }) |
23 | 25 | } |
0 commit comments