Skip to content

Commit

Permalink
ExampleErrorConstraint
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrkowalczuk committed May 30, 2016
1 parent f8511f9 commit bf50b4f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,30 @@ package pqt

import (
"errors"
"fmt"
"testing"

"github.com/lib/pq"
)

func ExampleErrorConstraint() {
expected := "pq: something goes wrong"
err := &pq.Error{
Table: "user",
Constraint: expected,
}

switch ErrorConstraint(err) {
case expected:
fmt.Println("expected constraint")
default:
fmt.Println("unknown constraint")
}

// Output:
// expected constraint
}

func TestErrorConstraint(t *testing.T) {
expected := "something"
err := &pq.Error{
Expand Down

0 comments on commit bf50b4f

Please sign in to comment.