vinokuma | f7605fc | 2023-06-02 18:08:01 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2023-present Open Networking Foundation |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | package onosnbi |
| 17 | |
| 18 | import ( |
| 19 | "net/http" |
| 20 | "net/http/httptest" |
| 21 | "testing" |
| 22 | ) |
| 23 | |
| 24 | func TestPortIgnoredHandle_PortsIgnoredServeHTTP(t *testing.T) { |
| 25 | req, err := http.NewRequest("GET", "/serve_http/", nil) |
| 26 | if err != nil { |
| 27 | t.Fatal(err) |
| 28 | } |
| 29 | |
| 30 | req.Header.Set("Content-Type", "application/json") |
| 31 | rr := httptest.NewRecorder() |
| 32 | |
| 33 | type args struct { |
| 34 | w http.ResponseWriter |
| 35 | r *http.Request |
| 36 | } |
| 37 | tests := []struct { |
| 38 | name string |
| 39 | pih *PortIgnoredHandle |
| 40 | args args |
| 41 | }{ |
| 42 | { |
| 43 | name: "PortIgnoredHandle_PortsIgnoredServeHTTP", |
| 44 | args: args{ |
| 45 | w: rr, |
| 46 | r: req, |
| 47 | }, |
| 48 | }, |
| 49 | } |
| 50 | for _, tt := range tests { |
| 51 | t.Run(tt.name, func(t *testing.T) { |
| 52 | pih := &PortIgnoredHandle{} |
| 53 | pih.PortsIgnoredServeHTTP(tt.args.w, tt.args.r) |
| 54 | }) |
| 55 | } |
| 56 | } |