-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project import generated by Copybara.
FolderOrigin-RevId: /usr/local/google/home/gdennis/copybara/temp/folder-destination6384971181149566477/.
- Loading branch information
GGN Engprod Team
authored and
greg-dennis
committed
Jan 31, 2023
1 parent
3b28896
commit 34623d2
Showing
20 changed files
with
59,349 additions
and
53,692 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Package eventlis provides an event listener API. | ||
package eventlis | ||
|
||
import ( | ||
"github.com/openconfig/ondatra/binding" | ||
"github.com/openconfig/ondatra/internal/events" | ||
) | ||
|
||
// EventListener is an event listener API. | ||
type EventListener struct{} | ||
|
||
// BeforeTestsEvent occurs after the reservation is complete and before tests | ||
// start executing. | ||
type BeforeTestsEvent struct { | ||
Reservation *binding.Reservation | ||
} | ||
|
||
// AfterTestsEvent occurs after the tests are finished executing and before | ||
// the reservation is released. | ||
type AfterTestsEvent struct { | ||
ExitCode *int | ||
} | ||
|
||
// AddBeforeTestsCallback adds a callback to run after the reservation is | ||
// complete and before tests start executing. | ||
func (el *EventListener) AddBeforeTestsCallback(cb func(*BeforeTestsEvent) error) { | ||
events.AddBeforeTests(func(res *binding.Reservation) error { | ||
return cb(&BeforeTestsEvent{Reservation: res}) | ||
}) | ||
} | ||
|
||
// AddAfterTestsCallback adds a callback to run after the tests are finished | ||
// executing and before the reservation is released. | ||
func (el *EventListener) AddAfterTestsCallback(cb func(*AfterTestsEvent) error) { | ||
events.AddAfterTests(func(exitCode *int) error { | ||
return cb(&AfterTestsEvent{ExitCode: exitCode}) | ||
}) | ||
} |
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
Oops, something went wrong.