Skip to content

Commit 9df2c66

Browse files
committed
Added unit-test for sketches module
1 parent 90bf1e3 commit 9df2c66

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

arduino/sketches/sketches_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// This file is part of arduino-cli.
2+
//
3+
// Copyright 2020 ARDUINO SA (http://www.arduino.cc/)
4+
//
5+
// This software is released under the GNU General Public License version 3,
6+
// which covers the main part of arduino-cli.
7+
// The terms of this license can be found at:
8+
// https://www.gnu.org/licenses/gpl-3.0.en.html
9+
//
10+
// You can be released from the requirements of the above licenses by purchasing
11+
// a commercial license. Buying such a license is mandatory if you want to
12+
// modify or otherwise use the software for commercial activities involving the
13+
// Arduino software without disclosing the source code of your own applications.
14+
// To purchase a commercial license, send an email to [email protected].
15+
16+
package sketches
17+
18+
import (
19+
"testing"
20+
21+
"github.com/arduino/go-paths-helper"
22+
"github.com/stretchr/testify/require"
23+
)
24+
25+
func TestSketchLoadingFromFolderOrMainFile(t *testing.T) {
26+
skFolder := paths.New("testdata/Sketch1")
27+
skMainIno := skFolder.Join("Sketch1.ino")
28+
29+
{
30+
sk, err := NewSketchFromPath(skFolder)
31+
require.NoError(t, err)
32+
require.Equal(t, sk.Name, "Sketch1")
33+
require.True(t, sk.FullPath.EqualsTo(skFolder))
34+
}
35+
36+
{
37+
sk, err := NewSketchFromPath(skMainIno)
38+
require.NoError(t, err)
39+
require.Equal(t, sk.Name, "Sketch1")
40+
require.True(t, sk.FullPath.EqualsTo(skFolder))
41+
}
42+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
void setup() {}
3+
void loop() {}

0 commit comments

Comments
 (0)