]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/go/thrift/transport_exception_test.go
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / jaegertracing / thrift / lib / go / thrift / transport_exception_test.go
CommitLineData
f67539c2
TL
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20package thrift
21
22import (
23 "fmt"
24 "io"
25
26 "testing"
27)
28
29type timeout struct{ timedout bool }
30
31func (t *timeout) Timeout() bool {
32 return t.timedout
33}
34
35func (t *timeout) Error() string {
36 return fmt.Sprintf("Timeout: %v", t.timedout)
37}
38
39func TestTExceptionTimeout(t *testing.T) {
40 timeout := &timeout{true}
41 exception := NewTTransportExceptionFromError(timeout)
42 if timeout.Error() != exception.Error() {
43 t.Fatalf("Error did not match: expected %q, got %q", timeout.Error(), exception.Error())
44 }
45
46 if exception.TypeId() != TIMED_OUT {
47 t.Fatalf("TypeId was not TIMED_OUT: expected %v, got %v", TIMED_OUT, exception.TypeId())
48 }
49}
50
51func TestTExceptionEOF(t *testing.T) {
52 exception := NewTTransportExceptionFromError(io.EOF)
53 if io.EOF.Error() != exception.Error() {
54 t.Fatalf("Error did not match: expected %q, got %q", io.EOF.Error(), exception.Error())
55 }
56
57 if exception.TypeId() != END_OF_FILE {
58 t.Fatalf("TypeId was not END_OF_FILE: expected %v, got %v", END_OF_FILE, exception.TypeId())
59 }
60}