$48 GRAYBYTE WORDPRESS FILE MANAGER $29

SERVER : in-mum-web1330.main-hosting.eu #1 SMP Mon Feb 10 22:45:17 UTC 2025
SERVER IP : 147.79.69.96 | ADMIN IP 216.73.216.215
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/go/pkg/mod/github.com/go-openapi/runtime@v0.26.0/

HOME
Current File : /opt/go/pkg/mod/github.com/go-openapi/runtime@v0.26.0//csv_test.go
// Copyright 2015 go-swagger maintainers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package runtime

import (
	"bytes"
	"io"
	"net/http/httptest"
	"testing"

	"github.com/stretchr/testify/assert"
)

const consProdCSV = `name,country,age
John,US,19
Mike,US,20
`

type csvEmptyReader struct{}

func (r *csvEmptyReader) Read(d []byte) (int, error) {
	return 0, io.EOF
}

func TestCSVConsumer(t *testing.T) {
	cons := CSVConsumer()
	reader := bytes.NewBuffer([]byte(consProdCSV))

	outBuf := new(bytes.Buffer)
	err := cons.Consume(reader, outBuf)
	assert.NoError(t, err)
	assert.Equal(t, consProdCSV, outBuf.String())

	outBuf2 := new(bytes.Buffer)
	err = cons.Consume(nil, outBuf2)
	assert.Error(t, err)

	err = cons.Consume(reader, struct{}{})
	assert.Error(t, err)

	emptyOutBuf := new(bytes.Buffer)
	err = cons.Consume(&csvEmptyReader{}, emptyOutBuf)
	assert.NoError(t, err)
	assert.Equal(t, "", emptyOutBuf.String())
}

func TestCSVProducer(t *testing.T) {
	prod := CSVProducer()
	data := []byte(consProdCSV)

	rw := httptest.NewRecorder()
	err := prod.Produce(rw, data)
	assert.NoError(t, err)
	assert.Equal(t, consProdCSV, rw.Body.String())

	rw2 := httptest.NewRecorder()
	err = prod.Produce(rw2, struct{}{})
	assert.Error(t, err)

	err = prod.Produce(nil, data)
	assert.Error(t, err)
}

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
25 Jan 2024 4.43 PM
root / root
0755
.github
--
25 Jan 2024 4.43 PM
root / root
0555
client
--
25 Jan 2024 4.43 PM
root / root
0555
fixtures
--
25 Jan 2024 4.43 PM
root / root
0555
flagext
--
25 Jan 2024 4.43 PM
root / root
0555
hack
--
25 Jan 2024 4.43 PM
root / root
0555
internal
--
25 Jan 2024 4.43 PM
root / root
0555
logger
--
25 Jan 2024 4.43 PM
root / root
0555
middleware
--
25 Jan 2024 4.43 PM
root / root
0555
security
--
25 Jan 2024 4.43 PM
root / root
0555
yamlpc
--
25 Jan 2024 4.43 PM
root / root
0555
.editorconfig
0.526 KB
25 Jan 2024 4.43 PM
root / root
0444
.gitattributes
0.017 KB
25 Jan 2024 4.43 PM
root / root
0444
.gitignore
0.047 KB
25 Jan 2024 4.43 PM
root / root
0444
.golangci.yml
0.699 KB
25 Jan 2024 4.43 PM
root / root
0444
CODE_OF_CONDUCT.md
3.157 KB
25 Jan 2024 4.43 PM
root / root
0444
LICENSE
11.092 KB
25 Jan 2024 4.43 PM
root / root
0444
README.md
0.705 KB
25 Jan 2024 4.43 PM
root / root
0444
authinfo_test.go
1.071 KB
25 Jan 2024 4.43 PM
root / root
0444
bytestream.go
4.137 KB
25 Jan 2024 4.43 PM
root / root
0444
bytestream_test.go
6.246 KB
25 Jan 2024 4.43 PM
root / root
0444
client_auth_info.go
1.16 KB
25 Jan 2024 4.43 PM
root / root
0444
client_operation.go
1.366 KB
25 Jan 2024 4.43 PM
root / root
0444
client_request.go
3.655 KB
25 Jan 2024 4.43 PM
root / root
0444
client_request_test.go
1.113 KB
25 Jan 2024 4.43 PM
root / root
0444
client_response.go
3.201 KB
25 Jan 2024 4.43 PM
root / root
0444
client_response_test.go
2.477 KB
25 Jan 2024 4.43 PM
root / root
0444
constants.go
1.664 KB
25 Jan 2024 4.43 PM
root / root
0444
csv.go
1.865 KB
25 Jan 2024 4.43 PM
root / root
0444
csv_test.go
1.764 KB
25 Jan 2024 4.43 PM
root / root
0444
discard.go
0.329 KB
25 Jan 2024 4.43 PM
root / root
0444
file.go
0.659 KB
25 Jan 2024 4.43 PM
root / root
0444
file_test.go
0.584 KB
25 Jan 2024 4.43 PM
root / root
0444
go.mod
1.254 KB
25 Jan 2024 4.43 PM
root / root
0444
go.sum
19.355 KB
25 Jan 2024 4.43 PM
root / root
0444
headers.go
1.114 KB
25 Jan 2024 4.43 PM
root / root
0444
headers_test.go
2.018 KB
25 Jan 2024 4.43 PM
root / root
0444
interfaces.go
3.99 KB
25 Jan 2024 4.43 PM
root / root
0444
json.go
1.117 KB
25 Jan 2024 4.43 PM
root / root
0444
json_test.go
1.471 KB
25 Jan 2024 4.43 PM
root / root
0444
request.go
3.33 KB
25 Jan 2024 4.43 PM
root / root
0444
request_test.go
5.06 KB
25 Jan 2024 4.43 PM
root / root
0444
statuses.go
2.515 KB
25 Jan 2024 4.43 PM
root / root
0444
text.go
2.821 KB
25 Jan 2024 4.43 PM
root / root
0444
text_test.go
4.952 KB
25 Jan 2024 4.43 PM
root / root
0444
values.go
0.483 KB
25 Jan 2024 4.43 PM
root / root
0444
values_test.go
0.596 KB
25 Jan 2024 4.43 PM
root / root
0444
xml.go
1.038 KB
25 Jan 2024 4.43 PM
root / root
0444
xml_test.go
1.438 KB
25 Jan 2024 4.43 PM
root / root
0444

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF