Skip to content

Commit 2b8e328

Browse files
committed
cleaned up tests - using //nolint:errcheck
1 parent bbcdae8 commit 2b8e328

File tree

2 files changed

+37
-26
lines changed

2 files changed

+37
-26
lines changed

pkg/rocket/rocket_test.go

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ func TestIgniteRocket(t *testing.T) {
2020
rocket := NewRocket("Saturn-V", "Nasa", 5, 25000)
2121
rocket.AddFuel(100)
2222

23-
_ = rocket.Ignite()
23+
//nolint:errcheck
24+
rocket.Ignite()
2425
got := rocket.Engines.Ignited
2526
want := true
2627

@@ -49,14 +50,16 @@ func TestThrottleUpEnginesNotIgnited(t *testing.T) {
4950
}
5051
}
5152

53+
//nolint:errcheck
5254
func TestThrottleUp(t *testing.T) {
5355
rocket := NewRocket("Saturn-V", "Nasa", 5, 25000)
5456
rocket.AddFuel(100)
5557

56-
_ = rocket.Ignite()
58+
rocket.Ignite()
59+
60+
rocket.ThrottleUp(100)
61+
rocket.ThrottleUp(100)
5762

58-
_, _ = rocket.ThrottleUp(100)
59-
_, _ = rocket.ThrottleUp(100)
6063
got, _ := rocket.ThrottleUp(100)
6164
want := 300
6265

@@ -65,13 +68,14 @@ func TestThrottleUp(t *testing.T) {
6568
}
6669
}
6770

71+
//nolint:errcheck
6872
func TestThrottleUpExceedMaxSpped(t *testing.T) {
6973
rocket := NewRocket("Saturn-V", "Nasa", 5, 25000)
7074
rocket.AddFuel(100)
7175

72-
_ = rocket.Ignite()
76+
rocket.Ignite()
7377

74-
_, _ = rocket.ThrottleUp(25000)
78+
rocket.ThrottleUp(25000)
7579
_, err := rocket.ThrottleUp(100)
7680

7781
if err == nil {
@@ -90,16 +94,17 @@ func TestThrottleDownEnginesNotIgnited(t *testing.T) {
9094
}
9195
}
9296

97+
//nolint:errcheck
9398
func TestThrottleDown(t *testing.T) {
9499
rocket := NewRocket("Saturn-V", "Nasa", 5, 25000)
95100
rocket.AddFuel(100)
96101

97-
_ = rocket.Ignite()
102+
rocket.Ignite()
98103

99-
_, _ = rocket.ThrottleUp(1000)
100-
_, _ = rocket.ThrottleUp(100)
101-
_, _ = rocket.ThrottleUp(100)
102-
_, _ = rocket.ThrottleDown(10)
104+
rocket.ThrottleUp(1000)
105+
rocket.ThrottleUp(100)
106+
rocket.ThrottleUp(100)
107+
rocket.ThrottleDown(10)
103108
got, _ := rocket.ThrottleDown(10)
104109
want := 1180
105110

@@ -108,31 +113,33 @@ func TestThrottleDown(t *testing.T) {
108113
}
109114
}
110115

116+
//nolint:errcheck
111117
func TestThrottleDownToUnder1000(t *testing.T) {
112118
rocket := NewRocket("Saturn-V", "Nasa", 5, 25000)
113119
rocket.AddFuel(100)
114120

115-
_ = rocket.Ignite()
121+
rocket.Ignite()
116122

117-
_, _ = rocket.ThrottleUp(900)
123+
rocket.ThrottleUp(900)
118124
_, err := rocket.ThrottleDown(10)
119125

120126
if err == nil {
121127
t.Errorf("Expected error when attempting to throttle down with resulting speed less than 1000")
122128
}
123129
}
124130

131+
//nolint:errcheck
125132
func TestCurrentSpeed(t *testing.T) {
126133
rocket := NewRocket("Saturn-V", "Nasa", 5, 25000)
127134
rocket.AddFuel(100)
128135

129-
_ = rocket.Ignite()
136+
rocket.Ignite()
130137

131-
_, _ = rocket.ThrottleUp(1000)
132-
_, _ = rocket.ThrottleUp(100)
133-
_, _ = rocket.ThrottleDown(10)
134-
_, _ = rocket.ThrottleUp(100)
135-
_, _ = rocket.ThrottleDown(5)
138+
rocket.ThrottleUp(1000)
139+
rocket.ThrottleUp(100)
140+
rocket.ThrottleDown(10)
141+
rocket.ThrottleUp(100)
142+
rocket.ThrottleDown(5)
136143

137144
got := rocket.CurrentSpeed()
138145
want := 1185

pkg/rocket/rocket_test2.go renamed to pkg/rocket/rocket_test_spec.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,36 @@ var _ = Describe("Rocket", func() {
4444
Expect(err).ShouldNot(HaveOccurred())
4545
})
4646

47+
//nolint:errcheck
4748
It("can throttle down successfully as long as it's resulting speed does not drop below 1000", func() {
48-
_, _ = rocket.ThrottleUp(2000)
49+
rocket.ThrottleUp(2000)
4950
speed, err := rocket.ThrottleDown(100)
5051
Expect(speed).Should(Equal(1900))
5152
Expect(err).ShouldNot(HaveOccurred())
5253
})
5354

55+
//nolint:errcheck
5456
It("will throw an error if it trys to throttle up and it's resulting speed exceeds its max speed", func() {
55-
_, _ = rocket.ThrottleUp(25000)
57+
rocket.ThrottleUp(25000)
5658
_, err := rocket.ThrottleUp(1)
5759

5860
Expect(err).Should(HaveOccurred())
5961
})
6062

63+
//nolint:errcheck
6164
It("will throw an error if it trys to throttle down and it's resulting speed is less than 1000", func() {
62-
_, _ = rocket.ThrottleUp(2000)
65+
rocket.ThrottleUp(2000)
6366
_, err := rocket.ThrottleDown(1500)
6467

6568
Expect(err).Should(HaveOccurred())
6669
})
6770

71+
//nolint:errcheck
6872
It("tracks it's current speed", func() {
69-
_, _ = rocket.ThrottleUp(2000)
70-
_, _ = rocket.ThrottleDown(5)
71-
_, _ = rocket.ThrottleDown(10)
72-
_, _ = rocket.ThrottleUp(200)
73+
rocket.ThrottleUp(2000)
74+
rocket.ThrottleDown(5)
75+
rocket.ThrottleDown(10)
76+
rocket.ThrottleUp(200)
7377

7478
Expect(rocket.CurrentSpeed()).Should(Equal(2185))
7579
})

0 commit comments

Comments
 (0)