Skip to content

Commit c933062

Browse files
authored
Merge pull request #10 from auyer/tests/update-matrix-modernize-example
Tests/update matrix modernize example
2 parents a6c248e + 2edd23c commit c933062

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

.github/workflows/test.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,22 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
go: [ 'stable', '^1.22', '^1.21', '^1.20', '^1.19', '~1.18', '~1.17', '~1.16', '~1.15', '~1.14', '~1.13', '~1.12' ]
12+
go: [
13+
'stable',
14+
'^1.24',
15+
'^1.23',
16+
'^1.22',
17+
'^1.21',
18+
'^1.20',
19+
'^1.19',
20+
'~1.18',
21+
'~1.17',
22+
'~1.16',
23+
'~1.15',
24+
'~1.14',
25+
'~1.13',
26+
'~1.12'
27+
]
1328
name: Go ${{ matrix.go }} sample
1429
steps:
1530
- name: Checkout repo
@@ -23,6 +38,7 @@ jobs:
2338
- name: Run Race tests
2439
run: |
2540
go test --race
41+
2642
coverage:
2743
runs-on: ubuntu-latest
2844
steps:
@@ -39,6 +55,6 @@ jobs:
3955
go test -coverprofile=coverage.txt -covermode=atomic
4056
4157
- name: Upload coverage report
42-
uses: codecov/codecov-action@v4
58+
uses: codecov/codecov-action@v5
4359
with:
4460
file: ./coverage.txt

examples/stego.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"flag"
77
"fmt"
88
"image"
9-
"io/ioutil"
109
"log"
1110
"os"
1211

@@ -55,7 +54,7 @@ func OpenImageFromPath(filename string) (image.Image, error) {
5554

5655
func main() {
5756
if encode {
58-
message, err := ioutil.ReadFile(messageInputFile) // Read the message from the message file (alternative to os.Open )
57+
message, err := os.ReadFile(messageInputFile) // Read the message from the message file (alternative to os.Open )
5958
if err != nil {
6059
print("Error reading from file!!!")
6160
return
@@ -103,7 +102,7 @@ func main() {
103102

104103
// if the user specifies a location to write the message to...
105104
if messageOutputFile != "" {
106-
err := ioutil.WriteFile(messageOutputFile, msg, 0644) // write the message to the given output file
105+
err := os.WriteFile(messageOutputFile, msg, 0644) // write the message to the given output file
107106

108107
if err != nil {
109108
fmt.Println("There was an error writing to file: ", messageOutputFile)

steganography_test.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@ func TestEncodeFromPngFile(t *testing.T) {
3939
if err != nil {
4040
log.Printf("Error Encoding file %v", err)
4141
t.FailNow()
42-
4342
}
43+
4444
outFile, err := os.Create(encodedInputFilePng)
4545
if err != nil {
4646
log.Printf("Error creating file %s: %v", encodedInputFilePng, err)
4747
t.FailNow()
48+
}
4849

50+
_, err = w.WriteTo(outFile)
51+
if err != nil {
52+
log.Printf("Error writing file %s: %v", encodedInputFilePng, err)
53+
t.FailNow()
4954
}
50-
w.WriteTo(outFile)
5155
defer outFile.Close()
5256
}
5357

@@ -57,8 +61,8 @@ func TestEncodeFromJpgFile(t *testing.T) {
5761
if err != nil {
5862
log.Printf("Error opening file %s: %v", rawInputFileJpg, err)
5963
t.FailNow()
60-
6164
}
65+
6266
defer inFile.Close()
6367

6468
reader := bufio.NewReader(inFile)
@@ -67,20 +71,25 @@ func TestEncodeFromJpgFile(t *testing.T) {
6771
log.Printf("Error decoding. %v", err)
6872
t.FailNow()
6973
}
74+
7075
w := new(bytes.Buffer)
7176
err = Encode(w, img, bitmessage) // Encode the message into the image file
7277
if err != nil {
7378
log.Printf("Error Encoding file %v", err)
7479
t.FailNow()
75-
7680
}
81+
7782
outFile, err := os.Create(encodedInputFileJpg)
7883
if err != nil {
7984
log.Printf("Error creating file %s: %v", encodedInputFileJpg, err)
8085
t.FailNow()
86+
}
8187

88+
_, err = w.WriteTo(outFile)
89+
if err != nil {
90+
log.Printf("Error writing file %s: %v", encodedInputFilePng, err)
91+
t.FailNow()
8292
}
83-
w.WriteTo(outFile)
8493
defer outFile.Close()
8594
}
8695

0 commit comments

Comments
 (0)