08/16/17 by Sergey Grebenshchikov
This is a quick tutorial on how to test code using the GoMock mocking library and the standard library testing package testing
.
GoMock is a mock framework for Go. It enjoys a somewhat official status as part of the github.com/golang organization, integrates well with the built-in testing
package, and provides a flexible expectation API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"database/sql" | |
"log" | |
) | |
func main() { | |
db, err := sql.Open("VENDOR_HERE", "YOUR_DSN_HERE") | |
handleError(err) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package router | |
import ( | |
"context" | |
"net/http" | |
gpath "path" | |
"github.com/julienschmidt/httprouter" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Scrollbar */ | |
/* From Quassel Wiki: http://sprunge.us/iZGB */ | |
QScrollBar { | |
background: #131313; | |
margin: 0; | |
} | |
QScrollBar:hover { | |
/* Optional: Subtle accent of scrolling area on hover */ | |
background: #161616; /* base +2 */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io" | |
"log" | |
"net/http" | |
) | |
type HttpConnection struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io" | |
"os" | |
) | |
var path = "/Users/novalagung/Documents/temp/test.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"encoding/gob" | |
"fmt" | |
"log" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io" | |
"log" | |
"net/http" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://localhost:8081/auth/js/keycloak.js" type="text/javascript"> | |
</script> | |
</head> | |
<body> | |
<h1>js-demo-app</h1> | |
NewerOlder