Initial commit: Lux mock library

This commit is contained in:
2025-08-18 13:18:24 -05:00
commit 45e74d07f8
5 changed files with 114 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (C) 2019-2024, Lux Industries Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+42
View File
@@ -0,0 +1,42 @@
# Lux Mock Library
Centralized mock utilities and helpers for the Lux ecosystem.
## Features
- **GoMock utilities**: Simplified gomock controller and matcher utilities
- **Mock generators**: Tools for generating mocks
- **Test helpers**: Common testing utilities
## Installation
```bash
go get github.com/luxfi/mock
```
## Usage
```go
import (
"github.com/luxfi/mock/gomock"
)
func TestExample(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
// Use your mocks here
}
```
## Generating Mocks
Use the standard mockgen tool:
```bash
mockgen -source=interface.go -destination=mocks/mock_interface.go -package=mocks
```
## License
See the LICENSE file for licensing terms.
+5
View File
@@ -0,0 +1,5 @@
module github.com/luxfi/mock
go 1.23
require go.uber.org/mock v0.5.0
+2
View File
@@ -0,0 +1,2 @@
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
+44
View File
@@ -0,0 +1,44 @@
// Copyright (C) 2019-2024, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package gomock
import (
"testing"
"go.uber.org/mock/gomock"
)
// NewController creates a new gomock.Controller
func NewController(t *testing.T) *gomock.Controller {
return gomock.NewController(t)
}
// Controller is a re-export of gomock.Controller
type Controller = gomock.Controller
// Call is a re-export of gomock.Call
type Call = gomock.Call
// Matcher is a re-export of gomock.Matcher
type Matcher = gomock.Matcher
// Any returns a matcher that matches any value of the specified type
func Any() Matcher {
return gomock.Any()
}
// Eq returns a matcher that matches values equal to x
func Eq(x interface{}) Matcher {
return gomock.Eq(x)
}
// Not returns a matcher that negates the given matcher
func Not(m Matcher) Matcher {
return gomock.Not(m)
}
// Nil returns a matcher that matches nil values
func Nil() Matcher {
return gomock.Nil()
}