github.com/arduino/arduino-cloud-cli@v0.0.0-20240517070944-e7a449561083/command/device/listfqbn_test.go (about)

     1  // This file is part of arduino-cloud-cli.
     2  //
     3  // Copyright (C) 2021 ARDUINO SA (http://www.arduino.cc/)
     4  //
     5  // This program is free software: you can redistribute it and/or modify
     6  // it under the terms of the GNU Affero General Public License as published
     7  // by the Free Software Foundation, either version 3 of the License, or
     8  // (at your option) any later version.
     9  //
    10  // This program is distributed in the hope that it will be useful,
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  // GNU Affero General Public License for more details.
    14  //
    15  // You should have received a copy of the GNU Affero General Public License
    16  // along with this program.  If not, see <https://www.gnu.org/licenses/>.
    17  
    18  package device
    19  
    20  import (
    21  	"testing"
    22  
    23  	"github.com/google/go-cmp/cmp"
    24  )
    25  
    26  func TestFilterFQBN(t *testing.T) {
    27  	var (
    28  		wrong = []FQBNInfo{
    29  			{Name: "Arduino Uno", Value: "arduino:avr:uno", Package: "arduino"},
    30  			{Name: "Arduino Industrial 101", Value: "arduino:avr:chiwawa", Package: "arduino"},
    31  			{Name: "SmartEverything Lion (Native USB Port)", Value: "Arrow:samd:SmartEverything_Lion_native", Package: "Arrow"},
    32  			{Name: "Arduino/Genuino 101", Value: "Intel:arc32:arduino_101", Package: "Intel"},
    33  			{Name: "Atmel atmega328pb Xplained mini", Value: "atmel-avr-xminis:avr:atmega328pb_xplained_mini", Package: "atmel-avr-xminis"},
    34  		}
    35  		good = []FQBNInfo{
    36  			{Name: "Arduino Nano RP2040 Connect", Value: "arduino:mbed_nano:nanorp2040connect", Package: "arduino"},
    37  			{Name: "Arduino MKR WiFi 1010", Value: "arduino:samd:mkrwifi1010", Package: "arduino"},
    38  			{Name: "ESP32 Dev Module", Value: "esp32:esp32:esp32", Package: "esp32"},
    39  			{Name: "4D Systems gen4 IoD Range", Value: "esp8266:esp8266:gen4iod", Package: "esp8266"},
    40  			{Name: "BPI-BIT", Value: "esp32:esp32:bpi-bit", Package: "esp32"},
    41  		}
    42  	)
    43  	all := append(wrong, good...)
    44  	filtered := filterFQBN(all)
    45  	if !cmp.Equal(good, filtered) {
    46  		t.Errorf("Wrong filter, diff:\n%s", cmp.Diff(good, filtered))
    47  	}
    48  }