alex-kar commented on PR #145: URL: https://github.com/apache/iceberg-go/pull/145#issuecomment-2342624384
@zeroshade Could you help me organize unit tests for `output.go`? I was
looking at how tests are organized in `github.com/pterm/pterm`, which prints
results in the terminal, and noticed that `github.com/MarvinJWendt/testza` is
used, but I can't get it to work.
That's what I try:
```go
// output_test.go
func TestDescribeTable(t *testing.T) {
meta, err := table.ParseMetadataBytes([]byte(ExampleTableMetadataV1))
if err != nil {
t.Errorf("Failed to parse table metadata %d", err)
}
table := table.New([]string{"t"}, meta, "", nil)
output, err := testza.CaptureStdout(func(w io.Writer) error {
text{}.DescribeTable(table)
return nil
})
testza.AssertEqual(t, "Expected", output)
}
```
And although I see result printed in terminal
```
Table format version | 2
Metadata location |
Table UUID | 9c12d441-03fe-4693-9a96-a0705ddf69c1
Last updated | 1602638573590
Sort Order | 3: [
| 2 asc nulls-first
| bucket[4](3) desc nulls-last
| ]
Partition Spec | [
| 1000: x: identity(1)
| ]
Current Schema, id=1
├──1: x: required long
├──2: y: required long (comment)
└──3: z: required long
Current Snapshot | append, {}: id=3055729675574597004,
parent_id=3051729675574597004, schema_id=1, sequence_number=1,
timestamp_ms=1555100955770, manifest_list=s3://a/b/2.avro
Snapshots
├──Snapshot 3051729675574597004, schema 1: s3://a/b/1.avro
└──Snapshot 3055729675574597004, schema 1: s3://a/b/2.avro
Properties
key | value
----------------------------------
read.split.target.size | 134217728
```
`testza` didn't capture stdout (line 7 - empty string)
```
--- FAIL: TestDescribeTable (0.00s)
output_test.go:102:
1| Two objects that should be equal, are not equal.
2|
3| Expected:
4| (string) (len=8) "Expected"
5|
6| Actual:
7| (string) ""
8|
9| Difference:
10| (1. -) Expected
11| (1. +)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
