From 4791ad3759de365af5f3fe2bfbfe4f43759e6a30 Mon Sep 17 00:00:00 2001 From: Kayra Date: Thu, 28 Mar 2024 12:05:48 +0300 Subject: [PATCH] moved example to example func in tests --- cmd/gocert/main.go | 14 -------------- internal/certdb/certdb_test.go | 9 +++++++++ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/cmd/gocert/main.go b/cmd/gocert/main.go index 2677c13..42d1148 100644 --- a/cmd/gocert/main.go +++ b/cmd/gocert/main.go @@ -1,19 +1,5 @@ package main -import ( - "fmt" - - "github.com/canonical/gocert/internal/certdb" -) - -var db *certdb.CertificateRequests - func main() { - db = new(certdb.CertificateRequests) - if err := db.Connect("./certs.db", "CertificateReq"); err != nil { - fmt.Println(err) - } - defer db.Disconnect() - // ListenAndServe } diff --git a/internal/certdb/certdb_test.go b/internal/certdb/certdb_test.go index 8cdd503..57b6de0 100644 --- a/internal/certdb/certdb_test.go +++ b/internal/certdb/certdb_test.go @@ -1,6 +1,7 @@ package certdb_test import ( + "log" "strings" "testing" @@ -106,3 +107,11 @@ func TestRetrieve(t *testing.T) { } } + +func ExampleConnection() { + db := new(certdb.CertificateRequests) + if err := db.Connect("./certs.db", "CertificateReq"); err != nil { + log.Fatalln(err) + } + defer db.Disconnect() +}