mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 18:15:42 +01:00
formatting
This commit is contained in:
parent
daab24eb2f
commit
3a7b411789
3 changed files with 17 additions and 22 deletions
|
|
@ -28,7 +28,7 @@ func TestNewPatternMatcher(t *testing.T) {
|
||||||
|
|
||||||
// Matches returns true if the given string matches any of the expressions.
|
// Matches returns true if the given string matches any of the expressions.
|
||||||
func TestMatches(t *testing.T) {
|
func TestMatches(t *testing.T) {
|
||||||
regex := []string{"a"}
|
regex := []string{"a"}
|
||||||
pm, _ := NewPatternMatcher(regex)
|
pm, _ := NewPatternMatcher(regex)
|
||||||
if !pm.Matches("a") {
|
if !pm.Matches("a") {
|
||||||
t.Errorf("Failure: Did not match two identical strings")
|
t.Errorf("Failure: Did not match two identical strings")
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,14 @@
|
||||||
package misc
|
package misc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
// CreateFormFile creates an [io.Writer] like [mime/multipart.Writer.CreateFromFile].
|
// CreateFormFile creates an [io.Writer] like [mime/multipart.Writer.CreateFromFile].
|
||||||
// This version allows to set the mime type, too.
|
// This version allows to set the mime type, too.
|
||||||
func TestCreateFormFile( t *testing.T) {
|
func TestCreateFormFile(t *testing.T) {
|
||||||
body := new(bytes.Buffer)
|
body := new(bytes.Buffer)
|
||||||
writer := multipart.NewWriter(body)
|
writer := multipart.NewWriter(body)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,10 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func TestNewTimeInterval(t *testing.T) {
|
func TestNewTimeInterval(t *testing.T) {
|
||||||
var before time.Time
|
var before time.Time
|
||||||
before = time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
|
before = time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
|
||||||
|
|
@ -24,7 +22,6 @@ func TestNewTimeInterval(t *testing.T) {
|
||||||
NewTimeInterval(after, before)
|
NewTimeInterval(after, before)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func TestGuessDate(t *testing.T) {
|
func TestGuessDate(t *testing.T) {
|
||||||
if _, guess := guessDate("2006-01-02T15:04:05"); !guess {
|
if _, guess := guessDate("2006-01-02T15:04:05"); !guess {
|
||||||
t.Errorf("Failure: Could not guess valid Date from valid string")
|
t.Errorf("Failure: Could not guess valid Date from valid string")
|
||||||
|
|
@ -34,7 +31,6 @@ func TestGuessDate(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func TestUnmarshalText(t *testing.T) {
|
func TestUnmarshalText(t *testing.T) {
|
||||||
testTimeRange := NewTimeInterval(
|
testTimeRange := NewTimeInterval(
|
||||||
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
|
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
|
||||||
|
|
@ -51,17 +47,17 @@ func TestUnmarshalText(t *testing.T) {
|
||||||
|
|
||||||
func TestMarshalJSON(t *testing.T) {
|
func TestMarshalJSON(t *testing.T) {
|
||||||
testTimeRange := NewTimeInterval(
|
testTimeRange := NewTimeInterval(
|
||||||
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
|
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
|
||||||
time.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC))
|
time.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC))
|
||||||
testTimeRange.MarshalJSON()
|
testTimeRange.MarshalJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnmarshalFlag(t *testing.T){
|
func TestUnmarshalFlag(t *testing.T) {
|
||||||
testTimeRange := NewTimeInterval(
|
testTimeRange := NewTimeInterval(
|
||||||
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
|
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
|
||||||
time.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC))
|
time.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC))
|
||||||
if err := testTimeRange.UnmarshalFlag("3h"); err != nil {
|
if err := testTimeRange.UnmarshalFlag("3h"); err != nil {
|
||||||
t.Errorf(err.Error())
|
t.Errorf(err.Error())
|
||||||
}
|
}
|
||||||
if err := testTimeRange.UnmarshalFlag("2006-01-02T15:04:05"); err != nil {
|
if err := testTimeRange.UnmarshalFlag("2006-01-02T15:04:05"); err != nil {
|
||||||
t.Errorf(err.Error())
|
t.Errorf(err.Error())
|
||||||
|
|
@ -84,6 +80,6 @@ func TestContains(t *testing.T) {
|
||||||
testTimeRange := NewTimeInterval(
|
testTimeRange := NewTimeInterval(
|
||||||
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
|
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
|
||||||
time.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC))
|
time.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC))
|
||||||
testPointInTime := time.Date(2010, time.March, 10, 23, 0, 0, 0, time.UTC)
|
testPointInTime := time.Date(2010, time.March, 10, 23, 0, 0, 0, time.UTC)
|
||||||
testTimeRange.Contains(testPointInTime)
|
testTimeRange.Contains(testPointInTime)
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue