2024-01-24 19:19:31 +01:00
|
|
|
/*
|
|
|
|
|
Copyright © 2023-2024 Thomas von Dein
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2024-01-27 17:23:09 +01:00
|
|
|
"bytes"
|
2024-01-24 19:19:31 +01:00
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// this is a weird thing. WriteImage() is being called in scrape.go
|
|
|
|
|
// which is being tested by TestMain() in main_test.go. However, it
|
|
|
|
|
// doesn't show up in the coverage report for unknown reasons, so
|
|
|
|
|
// here's a single test for it
|
|
|
|
|
func TestWriteImage(t *testing.T) {
|
2024-01-25 19:03:34 +01:00
|
|
|
t.Parallel()
|
|
|
|
|
|
2024-01-27 17:23:09 +01:00
|
|
|
reader := bytes.NewReader([]byte{1, 2, 3, 4, 5, 6, 7, 8})
|
2024-01-24 19:19:31 +01:00
|
|
|
file := "t/out/t.jpg"
|
|
|
|
|
|
2024-01-27 17:23:09 +01:00
|
|
|
err := WriteImage(file, reader)
|
2024-01-24 19:19:31 +01:00
|
|
|
if err != nil {
|
|
|
|
|
t.Errorf("Could not write mock image to %s: %s", file, err.Error())
|
|
|
|
|
}
|
|
|
|
|
}
|